I tried: @item.stuff<<thing and in thing I have: def stuff_id=(value) # remember old stuff_id cuz Rails has lousy trigger equivalent logger.debug ''set stuff_id called'' end And apparently stuff_id doesn''t get called, but the fk is changed directly in the database? I''m about to abandon trying to do trigger related stuff in Rails and go back to putting it in the database. Trying to do OLD/NEW trigger equivalents in Rails sucks. Joe -- Posted via http://www.ruby-forum.com/.
Jonathan Viney
2006-Mar-13 22:19 UTC
[Rails] has_many.collection<<obj doesn''t set attributes?
For stuff_id= to be called you need to do @item.stuff_id = thing.id. I assume you''re using belongs_to? You can also use the association callbacks: http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html -Jonathan. On 3/14/06, Joe <joe@yahoo.com> wrote:> > I tried: > > @item.stuff<<thing > > and in thing I have: > > def stuff_id=(value) > # remember old stuff_id cuz Rails has lousy trigger equivalent > logger.debug ''set stuff_id called'' > end > > And apparently stuff_id doesn''t get called, but the fk is changed > directly in the database? I''m about to abandon trying to do trigger > related stuff in Rails and go back to putting it in the database. Trying > to do OLD/NEW trigger equivalents in Rails sucks. > > Joe >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060313/cf2e302f/attachment.html