There is a way provided by devise gem to skip the Trackable fields updates for a specific request. Devise uses a condition as :
if record.respond_to?(:update_tracked_fields!) && warden.authenticated?(options[:scope]) && !warden.request.env["devise.skip_trackable"]
Above condition can be found at https://github.com/plataformatec/devise/blob/master/lib/devise/hooks/trackable.rb#L6
In whichever request you want to skip the Trackable fields updates you just need to set an variable devise.skip_trackable from environment as :
prepend_before_filter { env["devise.skip_trackable"] = true }
This will skip the updating of following columns: - sign_in_count
- current_sign_in_at
- last_sign_in_at
- current_sign_in_ip
- last_sign_in_ip
Please refer https://github.com/plataformatec/devise/issues/953#issue-717719 for more details.
On Saturday, May 3, 2014 8:43:21 AM UTC+5:30, Ankur wrote:
I am using switch_user rails gem to login as any other devise user from an admin account. When I use switch_user for an account, the devise session updates all the devise trackable attributes for that user such as:
t.integer "sign_in_count", t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip"
which I don't want to happen. These updates should happen only when an end user actually logs in and not for an admin account through switch_user.
How can I achieve this?
Thanks.
--Regards,
Ankur
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c81ed001-db2a-4cc3-8c2c-9217dc21622a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment