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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -