Ok, I'll start off with the basic models
Rating
  belongs_to :ratable, :polymorphic => true

Picture
  has_many :ratings, :as => :ratable
  belongs_to :user, :creator => true

Post
  has_many :ratings, :as => :ratable
  belongs_to :user, :creator => true

I'm wanting to be able to give an average for a user for all ratings
applied to their submissions.  There will be additional models in the
future that are ratable as well.

So, any ideas on a good way to approach this?  There are a couple of
simple ways but they won't scale.  And this relation will probably be
one of the most pushed that I'll have in the app.  So, I really need a
way to grab the rating for all ratables that belong to a user.  From
my current sense of things looks like I'm going to have to write some
SQL to do it but figured I'd ask anyway in case someone knew of a nice
trick to do sums across polymorphic types.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to