Has_many.collection<<obj doesn't set attributes?

I tried:


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’

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.


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



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs