Class: Refinery::PagesController

Inherits:
ApplicationController show all
Defined in:
pages/app/controllers/refinery/pages_controller.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) home

This action is usually accessed with the root path, normally '/'



9
10
11
# File 'pages/app/controllers/refinery/pages_controller.rb', line 9

def home
  render_with_templates?
end

- (Object) preview



41
42
43
44
45
46
47
48
49
50
51
# File 'pages/app/controllers/refinery/pages_controller.rb', line 41

def preview
  if page(fallback_to_404 = false)
    # Preview existing pages
    @page.attributes = params[:page]
  elsif params[:page]
    # Preview a non-persisted page
    @page = Page.new(params[:page])
  end

  render_with_templates?(:action => :show)
end

- (Object) show

This action can be accessed normally, or as nested pages. Assuming a page named "mission" that is a child of "about", you can access the pages with the following URLs:

GET /pages/about
GET /about

GET /pages/mission
GET /about/mission


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'pages/app/controllers/refinery/pages_controller.rb', line 23

def show
  if current_user_can_view_page?
    if should_skip_to_first_child?
      redirect_to refinery.url_for(first_live_child.url)
    elsif page.link_url.present?
      redirect_to page.link_url
    else
      if requested_friendly_id != page.friendly_id
        redirect_to refinery.url_for(page.url), :status => 301
      else
        render_with_templates?
      end
    end
  else
    error_404
  end
end