OT: SIT - how to turn it off

Pardon the intrusion but if somebody knows how to turn off Rails special
treatment of attributes ending in _type and _value I would dearly like
to have this information.

Workarounds are accepted too.

I am trying to initialise an associated row that contains the columns
identifier_type and identifier_value. The statement

model.association.create!(:column_type => ‘X’, :column_value => ‘Y’)

leaves association.column_type and association.column_value attributes
with VALUES NULL in the resulting generated SQL code. I really need
Rails to accept the values that I provide.

On Fri, Mar 20, 2009 at 3:32 PM, James B. [email protected]
wrote:

Pardon the intrusion but if somebody knows how to turn off Rails special
treatment of attributes ending in _type and _value I would dearly like
to have this information.

Workarounds are accepted too.

I am trying to initialise an associated row that contains the columns
identifier_type and identifier_value. The statement

model.association.create!(:column_type => ‘X’, :column_value => ‘Y’)

What type of association? There are many and they are all handled
quite differently.

leaves association.column_type and association.column_value attributes
with VALUES NULL in the resulting generated SQL code. I really need
Rails to accept the values that I provide.

David C. wrote:

What type of association? There are many and they are all handled
quite differently.

In this particular case this was a has_many / belongs_to pair and I was
attempting a parent.child.create({}) call. I discovered thereby that
Rails, at least in version 2.3.2, evidently does not permit mass
assignment of attributes ending in _type or _value; apparently
regardless of their presence in an attr_accessible call.

However, this problem proved serendipitous. In consequence I have
discovered a great deal regarding problems with mass assignment. The
result is that I have instead turned off mass assignment for the entire
application. This, needless to say, has broken a great deal of my tests
and functioning code but I am mostly finished resolving those problems.

I found a good discussion of this problem and some solutions at:

railspikes.com - This website is for sale! - railspikes Resources and Information.

James B. wrote:

In this particular case this was a has_many / belongs_to pair and I was
attempting a parent.child.create({}) call.

S/B: parent.children.create({})