On 21 July 2011 17:33, Tomas R. <li...@ruby-forum.com> wrote: > i tried to make a callback to assign the user IP address on create > > before_create > self.ip = request.remote_ip > end > > but I get > > NameError (undefined local variable or method `request' for > #<User:0x5b05078>):
I think (though not certain) that request is only available in the controller and since the callback is in the model then request is not available. Colin -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.