1

I have a model (say User), which has many logins.

class User < ActiveRecord::Base
    has_many :logins
end

class Login < ActiveRecord::Base
    belongs_to :user
end

Would it be possible to find users which have a particular login (say with provider == facebook.)

I know it could be done using:

User.joins{logins}.where{logins.provider == "facebook"}

But the resultant user entity objects are readonly... I know I can make it writable by calling readonly(true) on the resultant of where{} but somehow that feels wrong.

Is there no way of doing this without the explicit logins?

(using squeel syntax there)

kidoman
  • 2,402
  • 5
  • 26
  • 35

0 Answers0