ruby on rails - Query the associated table (without losing my hair) -
ruby on rails - Query the associated table (without losing my hair) -
ok, here's deal .. should simple, , i'm screwing sort of syntax somewhere:
i've got charge model has belongs_to relationship card.
i'd retrieve charges belong card name "john doe".
i've tried following, it's not working should (probably because i'm screwing syntax):
charge.where(card: [name: "john doe"]) help brother?
@floatingrock: seek this:
charge.joins(:card).where(cards: { name: 'john doe' }) as per requirment, first need bring together charge card , apply condition. hope works you.
ruby-on-rails rails-activerecord
Comments
Post a Comment