Class: Kuhsaft::PagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/kuhsaft/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
9
10
# File 'app/controllers/kuhsaft/pages_controller.rb', line 6

def index
  @search = params[:search]
  return if @search.blank?
  @pages = Kuhsaft::Page.unscoped.published.content_page.search(@search)
end

#lookup_by_idObject



26
27
28
29
# File 'app/controllers/kuhsaft/pages_controller.rb', line 26

def lookup_by_id
  @page = Page.find(params[:id])
  redirect_to "/#{@page.url}"
end

#showObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/kuhsaft/pages_controller.rb', line 12

def show
  if @page.present? && @page.redirect? && @page.redirect_url.present?
    redirect_url = @page.redirect_url.sub(/\A\/+/, '') # remove all preceding slashes
    session[:kuhsaft_referrer] = @page.id
    redirect_to "/#{redirect_url}"
  elsif @page.present?
    respond_with @page
  elsif @page.blank? && respond_to?(:handle_404)
    handle_404
  else
    raise ActionController::RoutingError, 'Not Found'
  end
end