Daniel Mantilla
2006-Aug-30 10:30 UTC
How can I make a property aware of changes on another?
I have a model that needs to update a property whenever another property changes, i.e. changing the model ''type'' property updates the ''description'' property with another value. I don''t know how to get access to the underlying fields handled by rails within a model class. Thanks, Daniel -- 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 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 -~----------~----~----~----~------~----~------~--~---
Hello Daniel,
It sounds like you are looking for the magic that makes the Observer
design pattern happen. In Ruby this is done using the Observable module.
Example code here ;
http://www.oreillynet.com/ruby/blog/2006/01/ruby_design_patterns_observer.html
FYI, I have NOT tried this under rails, but, I would be intrigued to
hear how you get along with it. Let us all know how it goes ;)
Regards
Stef
Daniel Mantilla wrote:> I have a model that needs to update a property whenever another property
> changes, i.e. changing the model ''type'' property updates
the
> ''description'' property with another value.
> I don''t know how to get access to the underlying fields handled by
rails
> within a model class.
>
> Thanks,
>
> Daniel
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---