Rails find through association

Posted by yogi on Stack Overflow See other posts from Stack Overflow or by yogi
Published on 2010-05-13T23:01:10Z Indexed on 2010/05/13 23:04 UTC
Read the original article Hit count: 138

Filed under:
class Customer < ActiveRecord::Base
    has_one     :address, :foreign_key => "customerid"
end

class Address < ActiveRecord::Base
    belongs_to :customer, :foreign_key => "customerid"
end

How do I find records in customer that do not have customerid in address table?

in SQL i'd do

select * from customer a, address b where a.customerid <> b.customerid

© Stack Overflow or respective owner

Related posts about rails