find from any table


If you have users and posts

You can User.find(blah blah) and Post.find(blah blah) - in both cases the relevant tables will be searched.
If you want to return users that have made posts in the last 10 minutes (assuming posts have user_id)

User.find(:all, :conditions => [‘posts.created_at > ?’,10.minutes.ago], :include => 'posts])

You will only get the users who posted in the last 10 minutes.

If you have @abc and you want to search the table associated with the records in @abc you can (assuming @abc is a collection of activerecord objects) do blah)

What this will do is get the class, from one of the elements in the collection. If @abc was a collection of users then
will be User. Before the constantize it will be “User”.

Anyway, thats about all I can say and probably all I should say - not really an expert here :slight_smile: