# User.protected\_attributes returning empty Set instead of nil -- causing activerecord/lib/base:2307

**URL:** <https://www.ruby-forum.com/t/user-protected-attributes-returning-empty-set-instead-of-nil-causing-activerecord-lib-base-2307/142716>\
**Category:** Rails\
**Created:** [July 10, 2008, 7:59pm UTC](https://www.ruby-forum.com/t/user-protected-attributes-returning-empty-set-instead-of-nil-causing-activerecord-lib-base-2307/142716 "2008-07-10T19:59:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [July 10, 2008, 7:59pm UTC](https://www.ruby-forum.com/t/user-protected-attributes-returning-empty-set-instead-of-nil-causing-activerecord-lib-base-2307/142716/1 "2008-07-10T19:59:12Z")

</div>

I have a model that uses attr\_accessible, and in my tests I get this:

RuntimeError (Declare either attr\_protected or attr\_accessible for  
User, but not both.):  
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
base.rb:2307:in `remove_attributes_protected_from_mass_assignment' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ base.rb:2114:in`attributes=’  
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
base.rb:2033:in `update_attributes' /app/controllers/accounts_controller.rb:50:in`update’

The model doesnt use attr\_protected. It turns out that  
User.protected\_attributes is returning an empty set instead of nil,  
which is what remove\_attributes\_protected\_from\_mass\_assignment wants.

The real fun part is that this only happens in tests (rake  
test:functional or ruby ./user\_controller\_test.rb). And for a real  
kick in the crotch, I’ve seen it in development but only once in about  
50 tries.

Anyone ever seen this?
