Class: ActionController::Base
- Inherits:
-
Metal
- Object
- Metal
- ActionController::Base
show all
- Defined in:
- lib/rails/actionpack/lib/action_controller/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.disclaimer(document_name, options = {}) ⇒ Object
5
6
7
8
9
|
# File 'lib/rails/actionpack/lib/action_controller/base.rb', line 5
def self.disclaimer(document_name, options = {})
before_filter(options) {|c| c.redirect_to_disclaimer(document_name)}
end
|
Instance Method Details
#disclaimer_exists?(document_name = nil) ⇒ Boolean
30
31
32
33
34
35
36
37
|
# File 'lib/rails/actionpack/lib/action_controller/base.rb', line 30
def disclaimer_exists?(document_name = nil)
if document_name and Disclaimer::Document.exists?(:name => document_name)
return true
else
Rails.logger.error "No disclaimer displayed as unable to find Disclaimer::Document with name '#{document_name || 'nil'}'"
return false
end
end
|
#disclaimer_has_been_accepted ⇒ Object
21
22
23
|
# File 'lib/rails/actionpack/lib/action_controller/base.rb', line 21
def disclaimer_has_been_accepted
session[:disclaimer] && session[:disclaimer][@disclaimer_document_name] == Disclaimer::ACCEPTED
end
|
#host_app_root_path ⇒ Object
39
40
41
|
# File 'lib/rails/actionpack/lib/action_controller/base.rb', line 39
def host_app_root_path
(Disclaimer.host_app_root_path || main_app.root_path).gsub(/\/$/, "")
end
|
#redirect_to_disclaimer(document_name) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/rails/actionpack/lib/action_controller/base.rb', line 11
def redirect_to_disclaimer(document_name)
return unless disclaimer_exists?(document_name)
@disclaimer_document_name = document_name.to_sym
unless disclaimer_has_been_accepted
store_disclaimer_return_location
document = Disclaimer::Document.find_by_name(@disclaimer_document_name)
redirect_to host_app_root_path + disclaimer.document_path(document)
end
end
|
#store_disclaimer_return_location ⇒ Object
25
26
27
28
|
# File 'lib/rails/actionpack/lib/action_controller/base.rb', line 25
def store_disclaimer_return_location
session[:disclaimer] ||= {}
session[:disclaimer][@disclaimer_document_name] = url_for(request.parameters)
end
|