Module: Refinery::ApplicationController

Extended by:
ActiveSupport::Concern
Included in:
AdminController
Defined in:
lib/refinery/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#admin?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/refinery/application_controller.rb', line 33

def admin?
  controller_name =~ %r{^admin/}
end

#error_404(exception = nil) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/refinery/application_controller.rb', line 37

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

Returns:

  • (Boolean)


46
47
48
# File 'lib/refinery/application_controller.rb', line 46

def from_dialog?
  params[:dialog] == 'true' or params[:modal] == 'true'
end

#home_page?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/refinery/application_controller.rb', line 50

def home_page?
  refinery.root_path =~ /^#{Regexp.escape(request.path.sub("//", "/"))}\/?/
end

#just_installed?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/refinery/application_controller.rb', line 54

def just_installed?
  Refinery::Role[:refinery].users.empty?
end

#local_request?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/refinery/application_controller.rb', line 58

def local_request?
  Rails.env.development? or request.remote_ip =~ /(::1)|(127.0.0.1)|((192.168).*)/
end

#login?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/refinery/application_controller.rb', line 62

def login?
  (controller_name =~ /^(user|session)(|s)/ and not admin?) or just_installed?
end