Sha256: 3de3b6901d90f548fbec2487c0394973d47489fb890248efd2a7ffd5ba0c80e4
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
class BaseController < ApplicationController class SectionRoutingError < ActionController::RoutingError; end helper :base, :resource, :content, :meta_tags helper HasFilter::Helper helper TableBuilder include CacheableFlash include ContentHelper include ResourceHelper before_action :set_site, :set_timezone attr_accessor :site, :section layout 'default' def site @site ||= Site.find_by_host!(request.host) end protected alias :set_site :site def sections @sections ||= site.sections end helper_method :sections def set_section @section ||= begin if params.key?(:section_permalink) sections.find_by_permalink!(params[:section_permalink]) else sections.first end end raise ActiveRecord::RecordNotFound unless @section.published?(true) || current_user.admin? @section end alias :section :set_section def set_timezone Time.zone = @site.timezone if @site end def current_page @page ||= begin page = params[:page].to_i page = 1 if page == 0 page end end def set_commentable @commentable = @article || @section || @site end def rescue_action(exception) if exception.is_a?(ActionController::RoleRequired) redirect_to_login(exception.message) else super end end def redirect_to_login(notice = nil) redirect_to login_url(return_to: request.url), notice: notice end def return_from(action, options = {}) CGI.unescape(params[:return_to] || options[:default] || '/') end def current_resource @section || @site end def skip_caching? @skip_caching or @article.try(:draft?) end def skip_caching! @skip_caching = true end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
adva-0.1.4 | app/controllers/base_controller.rb |
adva-0.1.3 | app/controllers/base_controller.rb |