in your Bed-model add has many :bookings, :through => :booking_items
then you should be able to call bookings_for_bed_1 = Bed.find(1).bookings
in your Bed-model add has many :bookings, :through => :booking_items
then you should be able to call bookings_for_bed_1 = Bed.find(1).bookings
Hi,
I added that and could get the bookings for a bed. but i wanted to get the bookings for a room using an association like:
room.bookings
i tried adding this using the nested has many plugin:
has_many :bookings, :through => :booking_items
to Room. but i got this error message.
Mysql::Error: Unknown column 'booking_items.roomActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'booking_items.room_id' in 'where clause': SELECT `bookings`.* FROM `bookings` INNER JOIN booking_items ON bookings.id = booking_items.booking_id WHERE ((`booking_items`.room_id = 1))
Am i better off just adding Room_Id to the BookingItem model and effectively denormalising it??
Thanks for the help.