# Cannot do mass\_assignment when inherited class?

**URL:** <https://www.ruby-forum.com/t/cannot-do-mass-assignment-when-inherited-class/170708>\
**Category:** Rails\
**Created:** [June 21, 2009, 3:47pm UTC](https://www.ruby-forum.com/t/cannot-do-mass-assignment-when-inherited-class/170708 "2009-06-21T15:47:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [June 21, 2009, 3:47pm UTC](https://www.ruby-forum.com/t/cannot-do-mass-assignment-when-inherited-class/170708/1 "2009-06-21T15:47:17Z")

</div>

I got the following error when trying to create the elibrary instance

(rdb:21) @elibrary = Elibrary.new(params[:elibrary])  
RuntimeError Exception: Declare either attr\_protected or  
attr\_accessible for Elibrary, but not both.

params : “elibrary”=\>{“title”=\>“bingo three”,  
“short\_description”=\>“something new”, “description”=\>“

fsdfgdsg\</  
p\>”}

Elibrary is declared as inherited from MediaItem, and attr are  
declared accessible in MediaItem…

class MediaItem \< ActiveRecord::Base  
belongs\_to :media\_container

# Behaviours

acts\_as\_nested\_set  
attr\_accessible :title, :short\_description, :description  
…

class Elibrary \< MediaItem  
end

when @elibrary = Elibrary.new, then assigning attributes to @elibrary,  
save is OK…

1- even duplicatiing the attr\_accessible in both classes doesn’t help  
2- acts\_as\_nested\_set brought additional fields … ant issue with it ?

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [June 22, 2009, 4:15pm UTC](https://www.ruby-forum.com/t/cannot-do-mass-assignment-when-inherited-class/170708/2 "2009-06-22T16:15:49Z")

</div>

The error is somewhere in your class declaration, but the message  
you’re getting doesn’t appear until you run attributes=.  
I’d look at the other plugins you’re using, as somebody’s calling  
attr\_protected on MediaItem.

–Mat Jones
