u = User.where("name = ?", "mateusz").limit(1)
u.class
=> ActiveRecord::Relation
So I cant do smth like u.email and so on. .find does right, returns User object. Is there any chance to get an User object from ActiveRecord::Relation object?
You should call first
or last
on the ActiveRecord::Relation
object:
u = User.where("name = ?", "mateusz").first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With