Class: Comatose::BaseController

Inherits:
ApplicationController show all
Defined in:
app/controllers/comatose/base_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#comatose_current_user, #find_page, #set_locale

Instance Method Details

#showObject

Render a specific page



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/comatose/base_controller.rb', line 9

def show
  page_name, page_ext = get_page_path
  page                = find_page(page_name, request)
  status              = nil
  if page.nil?
    status  = 404
    page    = find_page('404')
  end
  # if it's still nil, well, send a 404 status
  if page.nil?
    render :nothing => true, :status => status
    #raise ActiveRecord::RecordNotFound.new("Comatose page not found ")
  else
    # Make the page access 'safe'
    system_hash   = { 'current_user' => @current_user, 'view_context' => view_context }
    @page         = Comatose::PageWrapper.new(page, params.stringify_keys, system_hash)
    @current_user = current_user
    # For accurate uri creation, tell the page class which is the active mount point...
    Page.active_mount_info = get_active_mount_point(params[:index])
    rendered_text = page.to_comatose_html({
      'params'       => params.stringify_keys,
      'system'       => system_hash
    })
    render :text => rendered_text, :layout => get_page_layout, :status => status
  end
end