Sha256: 250a69f5db4a15699a2d115164c367fdc56854212247f5ca392ef3069eb71876
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
module Qbrick class PagesController < ::ApplicationController respond_to :html before_action :find_page_by_url, only: :show def index @search = params[:search] return if @search.blank? @pages = Qbrick::Page.unscoped.published.content_page.search(@search) end def show if redirect_page? redirect_url = @page.redirect_url.sub(%r{\A\/+}, '') # remove all preceding slashes session[:qbrick_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 redirect_page? @page.present? && @page.redirect? && @page.redirect_url.present? end def find_page_by_url url = locale.to_s url += "/#{params[:url]}" if params[:url].present? @page = Qbrick::Page.find_by_url(url) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
qbrick-2.5.2 | app/controllers/qbrick/pages_controller.rb |
qbrick-2.5.1 | app/controllers/qbrick/pages_controller.rb |
qbrick-2.5.0 | app/controllers/qbrick/pages_controller.rb |