I have devise authentication, he save ip and user count, but I need to save url's address, what current user see (get and post request).
Example: http://example/example?search....
How I save this example and others url's pages when user surfing on site.
You can use request.url
in the action of your controller to determine the requested URL.
Further to know, whether a request is of type GET
or POST
, you can use these two methods :
request.get?
OR
request.post?
For Rails 3.2 or Rails 4 you can use request.original_url
to get the current URL.
In your application_controller.rb
:
before_filter :save_url
def save_url
# here you should save request.original_url
end
You can specify actions's names in before_filter:
before_filter :save_url, :only => :index
If you render some view from more actions, not just index
, add them:
before_filter :save_url, :only => [:index,:name]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.