method
new
v2.1.0 -
Show latest stable
- Class:
ActionView::Base
new(view_paths = [], assigns_for_first_render = {}, controller = nil)public
No documentation available.
# File actionpack/lib/action_view/base.rb, line 221
def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)#:nodoc:
@assigns = assigns_for_first_render
@assigns_added = nil
@controller = controller
@finder = TemplateFinder.new(self, view_paths)
end 1Note
When using ActionView::Base.new to render templates views
when calling this method to render templates to a string. in order to use any helper methods you need to add them to the view like this
view = ActionView::Base.new(ActionController::Base.view_paths, {})
view.class_eval do
# include any needed helpers (for the view)
include ApplicationHelper
end
source: http://peden.biz/rendering-a-rails-view-from-a-script/