I have three models: company, event, event_space
company has many events event belongs to event space
now I want to get all events from a company where the event_space has virtual attribute set to true
c = Comapny.first
c.events.joins(:event_space).where("event_space.virtual = true")
I'm doing something wrong because I have
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: event_space.virtual: SELECT "events".* FROM "events" INNER JOIN "event_spaces" ON "event_spaces"."id" = "events"."event_space_id" WHERE "events"."company_id" = 2 AND (event_space.virtual = true)
event_spaces.virtual = true
(plural) – Alirezac.events.joins(:event_space).where(event_spaces: {virtual: true})
– Alireza