Class: Lookbook::PagesController

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationController

#not_found

Class Method Details

.controller_pathObject



5
6
7
# File 'app/controllers/lookbook/pages_controller.rb', line 5

def self.controller_path
  "lookbook/pages"
end

Instance Method Details

#indexObject



9
10
11
12
13
14
# File 'app/controllers/lookbook/pages_controller.rb', line 9

def index
  landing = Engine.pages.find(&:landing?) || Engine.pages.first
  raise_not_found("Page not found") unless landing.present?

  redirect_to lookbook_page_path(landing.path)
end

#showObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/lookbook/pages_controller.rb', line 16

def show
  @page = @pages.find_by_path(params[:path])
  raise_not_found("Page not found") unless @page

  @page_content = page_controller.render_page(@page)
  @title = @page.title
  @next_page = @pages.next(@page)
  @previous_page = @pages.previous(@page)
rescue ActionView::Template::Error => err
  raise Lookbook::TemplateError.new(
    original: err,
    file_path: @page.file_path,
    source: @page.content
  )
end