I have 3 models: Hotel, Room and Booking
Hotel has_many :rooms, and has_many :bookings
Room belongs_to :hotel, and habtm :bookings
Booking belongs_to :hotel, and habtm :rooms
i wish to add a condition to the @booking.rooms, they should share the
hotel.id as the booking and the collection itself, since a booking is
on a single hotel, not many. Â¿How can i accomplish that? It should be
something like :conditions => “hotel_id = self.hotel.id” (of course,
Another thing is that i don’t know if the operator “<<” can be
i redefine Booking.rooms << in some way, i could check if the collection
empty, and assign the hotel_id of the room beign added to the collection
The third thing/question/approach is that another way is to make Booking
“virtual” model, not beign saved directly until payment made, as Cart in
Agile dev with rails book.
Please, could you give me some advices?