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. -- Posted via http://www.ruby-forum.com/.
On Fri, Mar 20, 2009 at 3:32 PM, James Byrne <lists at ruby-forum.com> 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.> -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky 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: http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment -- Posted via http://www.ruby-forum.com/.