Form select not saving to the database

<%= f.label :type %>
<%= f.select(:type, [“original”,“print”,“other”]) %>

I have a photos model and added a drop-down list to the form, when the
option is selected, the correct parameters are passed but it is not
saved to the database.
I’ve googled this and looked at the api but I’m not sure what I’m doing.
In my photo model type is a string.

Is string the wrong field type? or anything else wrong?

the batman wrote:

<%= f.label :type %>
<%= f.select(:type, [“original”,“print”,“other”]) %>

I have a photos model and added a drop-down list to the form, when the
option is selected, the correct parameters are passed but it is not
saved to the database.
I’ve googled this and looked at the api but I’m not sure what I’m doing.
In my photo model type is a string.

Is string the wrong field type? or anything else wrong?

You’ve omitted the essential information to diagnose the problem.
What’s the form action? Are your routes correct? What shows in the log
as being posted in params? Are there any error messages?

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

the batman wrote:

<%= f.label :type %>
<%= f.select(:type, [“original”,“print”,“other”]) %>

I have a photos model and added a drop-down list to the form, when the
option is selected, the correct parameters are passed but it is not
saved to the database.
I’ve googled this and looked at the api but I’m not sure what I’m doing.
In my photo model type is a string.

Is string the wrong field type? or anything else wrong?

Oh, disregard my earlier post. I just realized what’s going on. Rails
reserves the field name “type” for STI purposes, and gets confused if
you try to use that name for an ordinary field.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Jun 15, 4:48 pm, the batman [email protected] wrote:

<%= f.label :type %>
<%= f.select(:type, [“original”,“print”,“other”]) %>

I have a photos model and added a drop-down list to the form, when the
option is selected, the correct parameters are passed but it is not
saved to the database.
I’ve googled this and looked at the api but I’m not sure what I’m doing.
In my photo model type is a string.

Is string the wrong field type? or anything else wrong?

If an attribute is named type Active Record will try and use it for
single table inheritance.

Fred

Marnen Laibow-Koser wrote:

the batman wrote:

<%= f.label :type %>
<%= f.select(:type, [“original”,“print”,“other”]) %>

I have a photos model and added a drop-down list to the form, when the
option is selected, the correct parameters are passed but it is not
saved to the database.
I’ve googled this and looked at the api but I’m not sure what I’m doing.
In my photo model type is a string.

Is string the wrong field type? or anything else wrong?

Oh, disregard my earlier post. I just realized what’s going on. Rails
reserves the field name “type” for STI purposes, and gets confused if
you try to use that name for an ordinary field.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

I recently encountered this same problem. I simply changed the column to
‘category’ and solved the problem. Though, it took far too long for me
to realise this.

On 16 June 2010 09:40, Pale H. [email protected] wrote:

[email protected]

I recently encountered this same problem. I simply changed the column to
‘category’ and solved the problem. Though, it took far too long for me
to realise this.

This is a useful page to refer to when strange things are going on
that do not seem to make sense.
http://wiki.rubyonrails.org/rails/pages/ReservedWords

Colin