jnunemaker/mongomapper — Issue #343: attr_accessible with no args not effective
Author: balexand
Created: 2011-11-06 19:25:48+00:00
State: open

In ActiveRecord, when `attr_accessible` is called with no args then attributes are filtered using an empty whitelist. MongoMapper is not consistent with this behavior:

class Foo
include MongoMapper::Document
attr_accessible

key :name, String
end

describe Foo do
# FAIL!
it "should not mass assign name in constructor" do
Foo.new(:name => "value").name.should_not == "value"
end
end

A workaround is to pass an attribute name that doesn't exist:

attr_accessible :no_attributes_accessible