Module: BackMark::ControllerMethods
- Defined in:
- lib/back_mark.rb
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- IGNORE_ACTIONS =
Pages/Actions which we don’t want to remember. We wouldnt ideally want to link back to new, edit, etc.,. We would only want to provide a link to the page that led to those pages
%w(new edit create update destroy)
Class Method Summary collapse
Instance Method Summary collapse
-
#back_mark_pages(options = {}) ⇒ Object
Add this as a before filter for marking the current request url.
Class Method Details
.included(controller) ⇒ Object
27 28 29 30 |
# File 'lib/back_mark.rb', line 27 def self.included(controller) controller.send :include, InstanceMethods controller.before_filter :back_mark_pages end |
Instance Method Details
#back_mark_pages(options = {}) ⇒ Object
Add this as a before filter for marking the current request url
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/back_mark.rb', line 87 def back_mark_pages( = {}) = {:force_mark => false}.merge() # Ignore AJAX requests since they cannot be linked back. # Also ignore actions in IGNORE_ACTIONS return if request.xhr? || (![:force_mark] && IGNORE_ACTIONS.include?(params[:action])) session[:filter_back_url] = session[:filter_prev_url] session[:filter_prev_url] = [:url] || request.url @marked_in_filter = true end |