MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Jun-26 12:57 UTC
ActiveRecord: Attribute Setter for belongs_to relation attribute
Hi, I m trying to link into the process of setting an belongs_to attribute in my model. Unfortunetly, it does not seem to be as easy as for "normal" attributes. I ve tried the following: class Treatment < ActiveRecord::Base belongs_to :drug def drug=(new_value) ''my stuff super new_value end However, that does not work. Ive also tried self[:drug] = new_value... However, that is also not working. Any ideas? Thanks a lot in advance. -- Volker --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2007-Jun-26 15:39 UTC
Re: ActiveRecord: Attribute Setter for belongs_to relation attribute
MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org wrote:> I m trying to link into the process of setting an belongs_to attribute > in my model. Unfortunetly, it does not seem to be as easy as for > "normal" attributes. > > I ve tried the following: > class Treatment < ActiveRecord::Base > belongs_to :drug > > def drug=(new_value) > ''my stuff > super new_value > end > > However, that does not work. Ive also tried self[:drug] = new_value... > However, that is also not working.http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/4fe057494c6e23e8 -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---