Sha256: f2b3e50c3f92d046dd22e8a57986acbcfaa9888214dd41bf4aa80fcea080a458
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Kuhsaft class PagesController < ::ApplicationController respond_to :html before_action :find_page_by_url, only: :show def index @search = params[:search] return if @search.blank? @pages = Kuhsaft::Page.unscoped.published.content_page.search(@search) end 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 def lookup_by_id @page = Page.find(params[:id]) redirect_to "/#{@page.url}" end private def find_page_by_url url = locale.to_s url += "/#{params[:url]}" if params[:url].present? @page = Kuhsaft::Page.published.find_by_url(url) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kuhsaft-2.6.3 | app/controllers/kuhsaft/pages_controller.rb |