method
new
v7.0.0 -
Show latest stable
- Class:
ActionView::Base
new(lookup_context, assigns, controller)public
No documentation available.
# File actionview/lib/action_view/base.rb, line 227
def initialize(lookup_context, assigns, controller) # :nodoc:
@_config = ActiveSupport::InheritableOptions.new
@lookup_context = lookup_context
@view_renderer = ActionView::Renderer.new @lookup_context
@current_template = nil
assign(assigns)
assign_controller(controller)
_prepare_context
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/