rails select from association using join -
rails select from association using join -
i have 3 models: company, event, event_space
company has many events event belongs event space
now want events company event_space has virtual attribute set true
c = comapny.first c.events.joins(:event_space).where("event_space.virtual = true")
i'm doing wrong because have
activerecord::statementinvalid: sqlite3::sqlexception: no such column: event_space.virtual: select "events".* "events" inner bring together "event_spaces" on "event_spaces"."id" = "events"."event_space_id" "events"."company_id" = 2 , (event_space.virtual = true)
you can modify where
clause follows right:
c.events.joins(:event_space).where(event_spaces: {virtual: true})
ruby-on-rails
Comments
Post a Comment