Class: Lookbook::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Lookbook::PagesController
- Defined in:
- app/controllers/lookbook/pages_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.controller_path ⇒ Object
3 4 5 |
# File 'app/controllers/lookbook/pages_controller.rb', line 3 def self.controller_path "lookbook/pages" end |
Instance Method Details
#index ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/lookbook/pages_controller.rb', line 7 def index landing = Lookbook.pages.find(&:landing) || Lookbook.pages.first if landing.present? redirect_to page_path landing.lookup_path else @title = "Not found" render "not_found" end end |
#show ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/lookbook/pages_controller.rb', line 17 def show @pages = Lookbook.pages @page = @pages.find_by_path(params[:path]) if @page if @page.errors.any? render "lookbook/error", locals: {error: @page.errors.first} else begin @page_content = page_controller.render_page(@page) @next_page = @pages.find_next(@page) @previous_page = @pages.find_previous(@page) @title = @page.title rescue => exception render "lookbook/error", locals: { error: Lookbook::Error.new(exception, file_path: @page.full_path, source_code: @page.content) } end end else render "not_found" end end |