I have a database that has stored information of some users.
I know for example: User.find(1)
will return the user with id:1
What should I call to find a user by email? I searched a lot but could not find anything.
I also tried User.find(:email => "[email protected]")
but it doesn't work.
Use
User.find_by_email("[email protected]")
Must check these two post from railscast (For rails3)
http://railscasts.com/episodes/202-active-record-queries-in-rails-3
http://railscasts.com/episodes/215-advanced-queries-in-rails-3
You can also query
User.where("email = ?", "[email protected]").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