Srdjan Pejic wrote:
> I don't know if STI is appropriate here.

On second thought, you're absolutely right.  I don't know what the heck 
I was thinking. :)

> 
> You should probably have a model called Rating which is the many side
> of one-to-many with the User model. The Rating model should be
> polymorphic so that you can use it to rate both Word and Quote
> objects.
[...]

Yeah, this is what I was trying for.  I just introduced STI in an 
inappropriate place.

Note, though, that *not* using STI makes foreign-key validation somewhat 
harder.

> 
> So, it would most likely look like this:
> 
> class User
>   :has_many => :ratings
> end
> 
> class Rating
>   :belongs_to => :user
>   :belongs_to => :rated, :polymorphic => true
> end
> 
> class Word
>   :has_one :rating, :as => :rated
> end
> 
> class Quote
>   :has_one :rating, :as => :rated
> end

Those should be has_many...

Best,
Marnen
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to