Rating Model - belongs_to :ratable, :polymorphic => true User Model & Comment Model & Picture Model - has_one :rating, :as => :ratable Okay, so now my "Ratings" table should have these columns: ups = 5 downs = 2 ratable_id = 3 ratable_type = "user" And that will automatically make user # 3 have user.rating.ups = 5 right? And the ratable_type will always use the singlular form, right? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anyone know if this is the best way to do this? On Jan 28, 3:20 pm, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Rating Model - belongs_to :ratable, :polymorphic => true > User Model & Comment Model & Picture Model - has_one :rating, :as > => :ratable > > Okay, so now my "Ratings" table should have these columns: > ups = 5 > downs = 2 > ratable_id = 3 > ratable_type = "user" > > And that will automatically make user # 3 have user.rating.ups = 5 > right? And the ratable_type will always use the singlular form, right?--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> And that will automatically make user # 3 have user.rating.ups = 5Yes> right? And the ratable_type will always use the singlular form, right?Yes -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
For some reason this isn''t working. I have done all that I stated above, then I made an object Rating with a ratable_id = 6, ratable_type = "web_page" But WebPages.find(6).rating returns a Nil. Ideas? On Jan 28, 6:17 pm, John Mangahas <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > And that will automatically make user # 3 have user.rating.ups = 5 > > Yes > > > right? And the ratable_type will always use the singlular form, right? > > Yes > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Does there need to be a middle table or something with Polymorphic? I didn''t see any mention of it. -Ryan On Jan 30, 5:50 pm, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For some reason this isn''t working. > > I have done all that I stated above, then I made an object Rating with > a ratable_id = 6, ratable_type = "web_page" > > But WebPages.find(6).rating returns a Nil. Ideas? > > On Jan 28, 6:17 pm, John Mangahas <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > > And that will automatically make user # 3 have user.rating.ups = 5 > > > Yes > > > > right? And the ratable_type will always use the singlular form, right? > > > Yes > > -- > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Not sure if this is the problem, but the descrimiator column (ratable_type in this case) should have a value that matches the camel cased class name. In your original post it looks like you have a lowercase ''u'' (user) instead of uppercase ("User"). Looking at a later post this appears to be the case. You should have "WebPage" as the ratable_type, not "web_page". HTH, AndyV PS: Any job posting dissections you want to share :-) On Jan 30, 9:01 pm, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Does there need to be a middle table or something with Polymorphic? I > didn''t see any mention of it. > > -Ryan > > On Jan 30, 5:50 pm, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > For some reason this isn''t working. > > > I have done all that I stated above, then I made an object Rating with > > a ratable_id = 6, ratable_type = "web_page" > > > But WebPages.find(6).rating returns a Nil. Ideas? > > > On Jan 28, 6:17 pm, John Mangahas <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > > > And that will automatically make user # 3 have user.rating.ups = 5 > > > > Yes > > > > > right? And the ratable_type will always use the singlular form, right? > > > > Yes > > > -- > > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---