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
Post a Comment