On May 16, 2010, at 6:20 PM, chewmanfoo wrote:

> I have a hosts class with an ip_addresses class which has a host_id
> attribute.  All hosts are associated with a data_center, and all
> ip_addresses are associated with a network.  Networks have a standard
> IP network definition (192.168.59.0/24) etc.  When a user changes that
> network definition, I need to go through all ip_addresses in the
> network and change them to agree with the new network definition.  For
> example, if the network is defined as 192.168.59.0/24, and the user
> changes it to 10.168.59.0/24 in the networks form, I need to change
> all the ip_addresses in that network to match the new scheme.  So I
> need to know when the network changes.  How do I do this?  Like, is
> there a way to add code to the function that sets the network
> definition?

Add an 'after_save' method to your Network model that checks to see what's 
changed and if appropriate goes through and changes all of it's IP_Address 
children...

-philip

-- 
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.

Reply via email to