On Jul 18, 2011, at 7:57 PM, mmmmbeeeeer wrote: > Hi, > > Looking for some help with the following... > > I have two models: > > --------------------------------------- > class User > > has_many :tasks > ... > end > --------------------------------------- > class Task > > belongs_to :owner, :class_name => "User", :creator => true > > .... > end > ---------------------------------------- > > This all works fine, but when I add 'children :tasks' to the User > class and try to view a user, the auto generated UI is throwing an > exception trying to find the tasks for a user by querying > tasks.user_id rather than tasks.owner_id.
You'll get the same error if you have a user in the console (in, say, @user) and do @user.tasks - the issue is that Rails doesn't know where to look for the foreign key. Changing your has_many to: has_many :tasks, :foreign_key => 'owner_id' should do the right thing. --Matt Jones -- 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.
