Sha256: ce2c106399f3ad81550a84297c4a8ead1aa2a941da170917677f9d63a2013cff
Contents?: true
Size: 1019 Bytes
Versions: 10
Compression:
Stored size: 1019 Bytes
Contents
module Kuhsaft class PagesController < ::ApplicationController respond_to :html before_action :find_page_by_url, only: :show def index @search = params[:search] if @search.present? @pages = Kuhsaft::Page.unscoped.published.content_page.search(@search) end end def show if @page.present? && @page.redirect? && @page.redirect_url.present? redirect_url = @page.redirect_url.sub(/\A\/+/, '') # remove all preceding slashes 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.find_by_url(url) end end end
Version data entries
10 entries across 10 versions & 1 rubygems