<%= 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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 15, 4:48 pm, the batman <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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> -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgI 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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 June 2010 09:40, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 >> marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.