method

new

new(context = nil, assigns = {}, controller = nil, formats = nil)
public

No documentation available.

# File actionpack/lib/action_view/base.rb, line 198
    def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:nodoc:
      @_config = ActiveSupport::InheritableOptions.new

      # Handle all these for backwards compatibility.
      # TODO Provide a new API for AV::Base and deprecate this one.
      if context.is_a?(ActionView::Renderer)
        @view_renderer = context
      elsif
        lookup_context = context.is_a?(ActionView::LookupContext) ?
          context : ActionView::LookupContext.new(context)
        lookup_context.formats  = formats if formats
        lookup_context.prefixes = controller._prefixes if controller
        @view_renderer = ActionView::Renderer.new(lookup_context)
      end

      assign(assigns)
      assign_controller(controller)
      _prepare_context
    end

1Note

When using ActionView::Base.new to render templates views

carlos_roque ยท Apr 17, 2018

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/