i need to modify default redirect_to method in actionpack/lib/action_controller/metal/redirecting.rb
def redirect_to(options = {}, response_status = {}) #:doc:
....
self.location = _compute_redirect_to_location(options)
# add customized code here to modify self.location
......
end
i am not sure what is the correct approach. what i did are the followings:
- copy redirecting.rb to my rails project in
“lib/rails_ext/action_controller/redirecting.rb” - made the change to redirect_to() method
- add the line: require ‘rails_ext/action_controller/redirecting’ in application.rb
it worked. however, i am getting an warning
rails_ext/action_controller/redirecting.rb:3: warning: already initialized constant DEFAULT_MESSAGE
in additional, i think there must be a better way to accomplish this.
I usually override this function in application controller.
similar article: http://jkfill.com/2011/05/13/log-which-line-called-redirect_to/