On 2 Jan 2009, at 17:36, Taylor Strait wrote: > > class Referral < ActiveRecord::Base > belongs_to :referer, > :class_name => :user, > :foreign_key => "referer_id" > > belongs_to :referee, > :class_name => :user, > :foreign_key => "referee_id" > > Most of this works. User.referrals returns all the referral objects. > Referral.referer and Referral.referee both return the appropriate > objects. But the User.referer/referee methods both raise the same > error: >
The class_name option should really be a string (ie :class_name => 'User') Fred >>> user.referer > TypeError: can't convert Symbol into String > > I would like User.referer to return the single user object that is > their > referer. And User.referees would return an array of user objects that > were refered. What am I doing wrong here? > -- > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

