ruby on rails - ActiveRecord find with joins and associations? -


i have model twitteruser has_one website shown in model below:

class twitteruser < activerecord::base     has_one :website, :foreign_key => :id, :primary_key => :website_id end 

i'm trying run query join twitteruser website , twitterusers' website has updated_at date > date, limited 10 rows.

i thought give me wanted, apparently it's not. what's wrong it?

twitteruser.includes().find(:all, :limit => 10, :conditions => ["websites.updated_at >= '2013-05-12 05:31:53.68059'"], :joins => :website) 

in database, twitter_users table consist of website_id field. websites table has id field.

this should work.

twitteruser.joins(:website).where("websites.updated_at >= '2013-05-12 05:31:53.68059'").limit(10) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -