Multiple login models
hurrycaner opened this issue · comments
Gustavo Schirmer commented
Hi, i have 3 different login models, and i want to set different authtrail tables for each one... The readme says to use bellow code for that, where should I put that? How do I make for use different authtrail tables for different models?
AuthTrail.track_method = proc do |info|
# code
end
Andrew Kane commented
Hey @hurrycaner, add this an initializer, like config/initializers/authtrail.rb
. You can use the data in the info
hash to write logic that uses different models.
Gustavo Schirmer commented
Okay, it worked just like this 👍
AuthTrail.track_method = proc do |info|
if info[:scope] == 'me_user'
login_activity = Me:LoginActivity.create!(info)
AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode
end
end