# This is really strange... I need help plz

**URL:** <https://www.ruby-forum.com/t/this-is-really-strange-i-need-help-plz/147677>\
**Category:** Rails\
**Created:** [September 4, 2008, 6:43am UTC](https://www.ruby-forum.com/t/this-is-really-strange-i-need-help-plz/147677 "2008-09-04T06:43:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [September 4, 2008, 6:43am UTC](https://www.ruby-forum.com/t/this-is-really-strange-i-need-help-plz/147677/1 "2008-09-04T06:43:43Z")

</div>

Hi everybody,

Here’s the story… I’m making an application that’s gonna help me  
manage my money when i go to the grocery store…nothing  
complicated… Here’s how i did the first coding:

script/generate scaffold Food name:string description:text type:string  
recurrence:string price:integer …

rake db:migrate

here is some excerpts of my controller and view respectively:

foods\_controller.rb

# GET /foods/new

# GET /foods/new.xml

def new  
@food = Food.new  
@type = [“Fruits & Vegetables”, “Grain Products”, “Meat &  
Alternatives”, “Milk Products”, “Beverages”, “Other”]  
@recurrence = [“Weekly”, “Biweekly”, “Monthly”]

```
respond_to do |format|
  format.html # new.html.erb
  format.xml { render :xml => @food }
end

```

end

new.html.erb

\<%= f.label :description %\>  
 \<%= f.text\_area :description %\>

\<%= f.label :type %\>  
 \<%= f.select :type, @type.collect { |t| [t, t] } %\>

\<%= f.label :recurrence %\>  
 \<%= f.select :recurrence, @recurrence.collect { |r| [r, r] } %\>

Everything looks OK… but when create a new Food, lets say a Tomato,  
everything is OK except for the “type” column in my db… if i go to  
the view it shows everything except “type” which is empty…

I don’t know what is wrong with the word “type”, cause i’ve tried the  
same application several times with different names (instead of  
“type”, i named my column “category”) and it worked… the only time  
it doesnt work is when the column name is “type”…

Why is that ???

Thank you guys for your help !

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [September 4, 2008, 9:48am UTC](https://www.ruby-forum.com/t/this-is-really-strange-i-need-help-plz/147677/2 "2008-09-04T09:48:41Z")

</div>

On 4 Sep 2008, at 06:43, Louis-Pierre wrote:

> Everything looks OK… but when create a new Food, lets say a Tomato,  
> everything is OK except for the “type” column in my db… if i go to  
> the view it shows everything except “type” which is empty…
> 
> I don’t know what is wrong with the word “type”, cause i’ve tried the  
> same application several times with different names (instead of  
> “type”, i named my column “category”) and it worked… the only time  
> it doesnt work is when the column name is “type”…

> Why is that ???

the type column is used for single table inheritance.

Fred

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [September 4, 2008, 3:43pm UTC](https://www.ruby-forum.com/t/this-is-really-strange-i-need-help-plz/147677/3 "2008-09-04T15:43:05Z")

</div>

> the type column is used for single table inheritance.
> 
> Fred
> 
> > Thank you guys for your help !

I see…

Thanks a lot !
