Module: Refinery::ApplicationController

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

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) admin?

Returns:

  • (Boolean)


31
32
33
# File 'core/lib/refinery/application_controller.rb', line 31

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

- (Object) error_404(exception = nil)



35
36
37
38
39
40
41
42
# File 'core/lib/refinery/application_controller.rb', line 35

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

- (Boolean) from_dialog?

Returns:

  • (Boolean)


44
45
46
# File 'core/lib/refinery/application_controller.rb', line 44

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

- (Boolean) home_page?

Returns:

  • (Boolean)


48
49
50
# File 'core/lib/refinery/application_controller.rb', line 48

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

- (Boolean) just_installed?

Returns:

  • (Boolean)


52
53
54
# File 'core/lib/refinery/application_controller.rb', line 52

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

- (Boolean) local_request?

Returns:

  • (Boolean)


56
57
58
# File 'core/lib/refinery/application_controller.rb', line 56

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

- (Boolean) login?

Returns:

  • (Boolean)


60
61
62
# File 'core/lib/refinery/application_controller.rb', line 60

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