i think self is a reserved word! shouldnt it be current_user? On Sun, Sep 12, 2010 at 8:23 AM, Heinz Strunk <[email protected]> wrote:
> Hello, > > I'm using the seeds.rb to create some user records: > 100.times do > user = User.new > user.username = Faker::Name.first_name > user.email = user.username+"@example.com" > user.save! > end > > This works just fine and the users have been created after I ran > db:seeds but what's not working is: > > after_create :write_comments > > protected > def write_comments > comment = Comment.new > comment.text = "some text" > comment.user = self > comment.save! > end > > There's not one single comment in the database but when I create a user > using the console the comment is created after I save the user. > > Anyone knows what's 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]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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.

