I\'m using Devise for authentication in my Rails app. I\'d like to eager load some of a users associated models in some of my controllers. Something like this:
c
Override serialize_from_session in your User
model.
class User
devise :database_authenticatable
def self.serialize_from_session key, salt
record = where(id: key).eager_load(:saved_listings, roles: :accounts).first
record if record && record.authenticatable_salt == salt
end
end
This will however, eager load on all requests.