# Rails 2.0.2 and Can't mass-assign these protected attributes

**URL:** <https://www.ruby-forum.com/t/rails-2-0-2-and-cant-mass-assign-these-protected-attributes/146089>\
**Category:** Rails\
**Created:** [August 17, 2008, 7:38pm UTC](https://www.ruby-forum.com/t/rails-2-0-2-and-cant-mass-assign-these-protected-attributes/146089 "2008-08-17T19:38:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 17, 2008, 7:38pm UTC](https://www.ruby-forum.com/t/rails-2-0-2-and-cant-mass-assign-these-protected-attributes/146089/1 "2008-08-17T19:38:18Z")

</div>

Hi there:

I’m playing around with a form that saves name, type and date for a  
kind of travels. At the controller I have this:  
@promotion = Promotion.new(params[:promotion])  
@promotion.save  
redirect\_to promotions\_path  
So yes, I mass-assign all the form data, but my model definition is  
empty actually (no “attr\_protected”, no “attr\_accessible” anywhere),  
but the message “WARNING: Can’t mass-assign these protected  
attributes: type” shows up every time and the value for “type” gets  
saved as empty (NULL) on development environment.

I’ve found this thread at the group but it doesn’t solve my problem:  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/fe5263558f73a514/ecee69cdf4676123?lnk=gst&q=Can’t+mass-assign+these+protected+attributes#ecee69cdf4676123](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/fe5263558f73a514/ecee69cdf4676123?lnk=gst&q=Can%27t+mass-assign+these+protected+attributes#ecee69cdf4676123)

Any ideas about what is protecting this attribute from myself?.

Cheers, Ibon.

---

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 17, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/rails-2-0-2-and-cant-mass-assign-these-protected-attributes/146089/2 "2008-08-17T20:01:44Z")

</div>

On 17 Aug 2008, at 18:37, txapelgorri wrote:

> but the message “WARNING: Can’t mass-assign these protected  
> attributes: type” shows up every time and the value for “type” gets  
> saved as empty (NULL) on development environment.

type is a magic column name (used for STI). You can change the magic  
STI column to something else with inheritance\_column

Fred

---

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 17, 2008, 8:09pm UTC](https://www.ruby-forum.com/t/rails-2-0-2-and-cant-mass-assign-these-protected-attributes/146089/3 "2008-08-17T20:09:21Z")

</div>

Hi Fred:

Appreciate the clarifying comment. I think that I have prefer to  
change my column name rather than the magic one. By the way, what does  
STI means?.

Cheers, Ibon.

---

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 17, 2008, 8:12pm UTC](https://www.ruby-forum.com/t/rails-2-0-2-and-cant-mass-assign-these-protected-attributes/146089/4 "2008-08-17T20:12:18Z")

</div>

On 17 Aug 2008, at 19:08, txapelgorri wrote:

> Hi Fred:
> 
> Appreciate the clarifying comment. I think that I have prefer to  
> change my column name rather than the magic one. By the way, what does  
> STI means?.

Depending on the context, Single Table Inheritance or Sexually  
Transmitted Infection.

Fred

---

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 17, 2008, 8:36pm UTC](https://www.ruby-forum.com/t/rails-2-0-2-and-cant-mass-assign-these-protected-attributes/146089/5 "2008-08-17T20:36:54Z")

</div>

XD

Thanks.
