I have two tables, “users” and “users_emails”.
users have the following columns: |id|name|
users_emails have the following columns: |user_id|email|
The classes look like the following:
class UsersEmail< ActiveRecord::Base
class User< ActiveRecord::Base
What is the best way (the rails way using ActiveRecord methods) to find
a user based on “User.name” and “UsersEmail.email”. I want the User who
has a particular name and particular email.
I can do something like:
User.find(:all, :condition[“name = :name”, ‘joe’],
:join => [“do a join on Users and UsersEmail”])
where I specify the user.name in the :condition, but I was wondering if
there is a better way of doing this (without explicitly witting out the
Any help would be greatly appreciated.