Tuesday 15 March 2011

activerecord - Rails has_many through singular association -


This is probably quite simple, but I am still unable to wrap my head around the problem.

I have 3 tables ... (better than that), but 3 in this scenario is this thing.

Placement Bookings and Ratings

Places have_many bookings

Each booking has a rating (because the user only rates one time) and related_ from (A) Place < / P>

Ratings are related (A) Booking

So even though there is only one rating in the booking, places have locations due to ratings through booking, there are many more booking places too.

But does it seem to work? All the rest seem to be.

There is a place_ID in the booking and booking_id in the ratings, and I have been successful through all the other organizations ... is not it just? any idea? Thanks

Apart from this: If I change the booking to a hotmee: Ratings do this ... but booking will be a rating for only one booking ... so this is not a good thing.

  Invalid source reflection macro: has_one has_many: ratings, via = & gt; : Bookings. Use: Source  

is to specify the reflection of the source: medium: By means of joining this model ; See the following railway tickets for details:

  • If possible, the best solution is to modify your relationships. > Has_one instead of rating a booking related_to one rating.


    No comments:

    Post a Comment