On 14 February 2012 14:05, Dave Aronson <[email protected]> wrote: > On Tue, Feb 14, 2012 at 05:05, Michael Pavling <[email protected]> wrote: > >> You want to look online for "rails self referential associations" >> >> But essentially, in your User model add: >> belongs_to :author, :class_name => "User" >> >> and add a migration for the author_id field to be added to the users table. > > I think one of us (maybe more!) has misinterpreted what Marcos wanted. > I think he wants to do that on Posts, not Users.
Ah yes, sorry, I've galloped through and grabbed the wrong end of the stick. Here's another gallop :-) # posts model belongs_to :user belongs_to :author, :class_name => "User" and add a migration for the author_id field to be added to the posts table. Same principle of changing the class_name for the association - just putting it on the right model this time! :-D -- 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.

