Method: Cms::ViewContext#initialize

Defined in:
app/models/cms/view_context.rb

#initialize(controller, attributes_to_assign) ⇒ ViewContext

Returns a new instance of ViewContext.

Parameters:

  • controller (ActionController::Base)

    The CMS controller rendering the overall page

  • attributes_to_assign (Hash)

    All the values that should be passed to this View as @attributes available.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/cms/view_context.rb', line 21

def initialize(controller, attributes_to_assign)
  @controller = controller
  super(@controller.view_paths, attributes_to_assign, @controller)


  helpers = controller.class._helpers
  self.class.send(:include, helpers)

  # Make all Route helpers available in the view, i.e. cms_xyz_path and cms_xyz_url
  self.class.send(:include, Cms::Engine.routes.url_helpers)

  # Need to add Cms::PageRoute helpers to the view
  self.class.send(:include, Rails.application.routes.url_helpers)

  # See what values are getting copied into template
#      Rails.logger.warn "Assigned these variables: #{attributes_to_assign}"

end