Module: Refinery::ApplicationController
- Included in:
- AdminController
- Defined in:
- lib/refinery/application_controller.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
Extend controller.
Instance Method Summary collapse
- #admin? ⇒ Boolean
- #current_refinery_user ⇒ Object
- #error_404(exception = nil) ⇒ Object
- #from_dialog? ⇒ Boolean
- #home_page? ⇒ Boolean
- #local_request? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
Extend controller
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/refinery/application_controller.rb', line 6 def self.included(base) # Extend controller base.helper_method :home_page?, :local_request?, :from_dialog?, :admin?, :current_refinery_user, :authorisation_manager, :authorization_manager base.protect_from_forgery with: :exception # See ActionController::RequestForgeryProtection base.send :include, Refinery::Crud # basic create, read, update and delete methods if Refinery::Core.rescue_not_found base.rescue_from ::ActiveRecord::RecordNotFound, ::AbstractController::ActionNotFound, ::ActionView::MissingTemplate, :with => :error_404 end end |
Instance Method Details
#admin? ⇒ Boolean
26 27 28 |
# File 'lib/refinery/application_controller.rb', line 26 def admin? %r{\Aadmin/} === controller_name end |
#current_refinery_user ⇒ Object
51 52 53 |
# File 'lib/refinery/application_controller.rb', line 51 def current_refinery_user .current_user end |
#error_404(exception = nil) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/refinery/application_controller.rb', line 30 def error_404(exception = nil) # fallback to the default 404.html page. file = Rails.root.join 'public', '404.html' file = Refinery.roots('refinery/core').join('public', '404.html') unless file.exist? render :file => file.cleanpath.to_s.gsub(%r{#{file.extname}$}, ''), :layout => false, :status => 404, :formats => [:html] return false end |
#from_dialog? ⇒ Boolean
39 40 41 |
# File 'lib/refinery/application_controller.rb', line 39 def from_dialog? params[:dialog] == 'true' || params[:modal] == 'true' end |
#home_page? ⇒ Boolean
43 44 45 |
# File 'lib/refinery/application_controller.rb', line 43 def home_page? %r{^#{Regexp.escape(request.path)}} === refinery.root_path end |
#local_request? ⇒ Boolean
47 48 49 |
# File 'lib/refinery/application_controller.rb', line 47 def local_request? Rails.env.development? || /(::1)|(127.0.0.1)|((192.168).*)/ === request.remote_ip end |