This is really strange... I need help plz

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 !

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

the type column is used for single table inheritance.

Fred

Thank you guys for your help !

I see…

Thanks a lot !