Mass Assginment and has_many

Typically, when one creates a has_many associated table one does this:{attribute hash},{attribute hash},…} or
hasone.hasmany.create({attribute hash}, …

However, if mass assignment is turned off (attr_accessible => nil), then
I cannot seem to set the attributes directly.

For example, in a console session I do this:

me =
=> …

me.attribute = …!
=> true

mi =
=> …

=> 1

mi.identifier_type = ‘post’
=> ‘post’

=> nil

What is going on and how do I directly set association attributes?

Rails 2.3.2

This seems related specifically to the suffices _type and _value.
Attributes ending in either of these strings are not processed by the
attribute= method. if #write_attribute(“something_type”, “a value”) is
called instead, then the somthing-type= method is again bypassed and the
attribute is set to the literal value provided instead.

I have raised a ticket for this:

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