Class: WCC::Contentful::App::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- WCC::Contentful::App::PagesController
show all
- Includes:
- PreviewPassword
- Defined in:
- app/controllers/wcc/contentful/app/pages_controller.rb
Instance Method Summary
collapse
#preview?, #preview_password
Instance Method Details
#index ⇒ Object
8
9
10
11
12
|
# File 'app/controllers/wcc/contentful/app/pages_controller.rb', line 8
def index
@page = global_site_config&.homepage ||
page_model.find_by(slug: '/', options: { include: 3, preview: preview? })
render 'pages/show'
end
|
#show ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/wcc/contentful/app/pages_controller.rb', line 14
def show
slug = "/#{params[:slug]}"
@page = page_model.find_by(slug: slug, options: { include: 3, preview: preview? })
return render 'pages/show' if @page
redirect = redirect_model.find_by(slug: slug, options: { include: 0, preview: preview? })
raise WCC::Contentful::App::PageNotFoundError, slug unless redirect
redirect_to redirect.href
end
|