Hi. Given:
class Group < AR
has_many :users
end
Is it in any way possible to retain reference to the old users when
they get replaced using group.users=(new_users) ?
The below doesn''t work but illustrates what I''m looking for:
class Group < AR
has_many :users
def users=(new_users)
@old_users = users
write_attribute(''users'', new_users)
end
end
I need to examine the differences when related objects (in this case
users) change.
Morten
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> The below doesn''t work but illustrates what I''m looking for: > > class Group < AR > has_many :users > def users=(new_users) > @old_users = users > write_attribute(''users'', new_users) > end > endI''m currently doing something like this: class Group < AR has_many :users def validate_on_update old_users = Group.find(id).users #Do the checks here.. end end But that''s nasty. Anyone know if there''s a plugin that allows AR to contain a version of the object in the state it had as it got read from the DB for later comparison? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---