Class: PagesController

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

Instance Method Summary collapse

Methods inherited from ForestController

#after_sign_in_path_for

Instance Method Details

#editObject



25
26
27
28
29
30
31
32
# File 'app/controllers/pages_controller.rb', line 25

def edit
  @page = Page.where(path: params[:page_path]).try(:first)
  if @page
    return redirect_to edit_admin_page_path(@page)
  else
    return redirect_to admin_pages_path
  end
end

#showObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/pages_controller.rb', line 4

def show
  unless @page
    if Rails.configuration.consider_all_requests_local
      raise ActionController::RoutingError.new('Not Found')
    else
      logger.error("[Forest][Error] 404 page not found. Looked for path \"#{request.fullpath.force_encoding('utf-8')}\"")
      @body_classes ||= []
      @body_classes << 'controller--errors action--not_found'
      @page_title = '404 - Not Found'
      return render 'errors/not_found'
    end
  end
  authorize @page

  if @page.redirect.present?
    return redirect_to @page.redirect
  end

  @body_classes << "page--#{@page.slug}"
end