Problem with Rails3.1.1 in mass_assignment_authorizer

By accident I had Rails-3.1.1 installed by bundler. However, when I discovered this mishap during my feature run I encountered this error in many places:

wrong number of arguments (1 for 0) (ArgumentError)       /home/byrnejb/.rvm/gems/ruby-1.8.7-p352/gems/activemodel-3.1.1/ lib/active_model/mass_assignment_security.rb:209:in `mass_assignment_authorizer'       /home/byrnejb/.rvm/gems/ruby-1.8.7-p352/gems/activemodel-3.1.1/ lib/active_model/mass_assignment_security.rb:209:in `sanitize_for_mass_assignment'       /home/byrnejb/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-3.1.1/ lib/active_record/base.rb:1744:in `assign_attributes'       /home/byrnejb/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-3.1.1/ lib/active_record/base.rb:1567:in `initialize'       /home/byrnejb/.rvm/gems/ruby-1.8.7-p352/gems/activerecord-3.1.1/ lib/active_record/reflection.rb:190:in `new'

Everything was working on Friday last with Rails-3.0.9 and no changes to the code or the features have been made. I am therefore somewhat curious as to what might be causing this. I previously had mass assignment turned off in an initializer:

$ cat config/initializers/attr_accessible_nil.rb #ActiveRecord::Base.send(:attr_accessible, nil)

So, I am wondering if this might be the cause of the problem. Note that I have no intention of moving to Rails-3.1.1 at the moment. I am just curious as to what would be causing this error.

I found my problem is a library I wrote to turn off mass assignment . In it I am calling this:

  # override AR method   def mass_assignment_authorizer     if accessible == :all       self.class.protected_attributes     else       super + ( accessible || )     end   end

Mass_assignment_authorizer has a different signature in Rails 3.1 thus the problem. By my way of thinking the signature change means that we should be talking of Rails-4.0.1 instead of Rails-3.1.1. But, then again, given what has happened to Firefox perhaps not.

You can't expect every single internal rails method not to change between rails versions (although public methods should certainly not change signature like that). One of the things 3.0 was supposed to bring was greater clarity about what bits of the internals could be depended upon in this manner and which couldn't. Part of that involved breaking up action controller into more reusable components, but I'm not sure where things got to with active record.

Fred