On 12 May 2010 03:15, Nadal <[email protected]> wrote: > class User < AR > end > > user = User.new > > > Let's say that I have a user instance with me. After this record is > saved I want an after_save callback which would print the id of the > record. > The only catch is that I am not allowed to change the User class. How > can I accomplish my goal? Is that even possible to add an after_save > callback on a particular instance object. Any metaprogramming hack. > I'm sure ruby does provide some tool. > > > This would be a trivial issue if I were allowed to change the User > class but I am not.
What do you mean by 'not allowed to change the User class'? Do you mean that you are not allowed to change the file user.rb? If so that is not a problem as you can modify or extend the class in another loaded file merely by providing class User < ... and providing new or modified methods there. 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 [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. > > -- 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.

