<%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt =>true}) %> produces: <select id="user_type" name="user[type]"><option value="">Please select</option> <option value="3">Hygenist</option> <option value="4">Assistant</option> <option value="2">Doctor</option> <option value="1">Practice</option></select> </p> and the form returns a string. how do i get the form to submit an int.. or get AR to convert it? select fields can return an int right? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
params[:user][:type].to_i All int''s submitted by fields are actually submitted as strings. Same goes for dates and anything else, it''s always a string. On Jan 4, 2008 1:02 PM, spokra <spokra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > <%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, > "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt > =>true}) %> > > produces: > > > <select id="user_type" name="user[type]"><option value="">Please > select</option> > <option value="3">Hygenist</option> > <option value="4">Assistant</option> > <option value="2">Doctor</option> > <option value="1">Practice</option></select> </p> > > > and the form returns a string. how do i get the form to submit an > int.. or get AR to convert it? select fields can return an int right? > > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
this would be in the controller in create and update then? On Jan 3, 6:44 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> params[:user][:type].to_i > > All int''s submitted by fields are actually submitted as strings. Same goes > for dates and anything else, it''s always a string. > > On Jan 4, 2008 1:02 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > <%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, > > "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt > > =>true}) %> > > > produces: > > > <select id="user_type" name="user[type]"><option value="">Please > > select</option> > > <option value="3">Hygenist</option> > > <option value="4">Assistant</option> > > <option value="2">Doctor</option> > > <option value="1">Practice</option></select> </p> > > > and the form returns a string. how do i get the form to submit an > > int.. or get AR to convert it? select fields can return an int right? > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Indeed On Jan 4, 2008 1:18 PM, spokra <spokra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > this would be in the controller in create and update then? > > > On Jan 3, 6:44pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > params[:user][:type].to_i > > > > All int''s submitted by fields are actually submitted as strings. Same > goes > > for dates and anything else, it''s always a string. > > > > On Jan 4, 2008 1:02 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > > > > > <%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, > > > "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt > > > =>true}) %> > > > > > produces: > > > > > <select id="user_type" name="user[type]"><option value="">Please > > > select</option> > > > <option value="3">Hygenist</option> > > > <option value="4">Assistant</option> > > > <option value="2">Doctor</option> > > > <option value="1">Practice</option></select> </p> > > > > > and the form returns a string. how do i get the form to submit an > > > int.. or get AR to convert it? select fields can return an int right? > > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text > - > > > > - Show quoted text - > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
forgive me I''m a newbie... I''ve tried both params[:user][:type].to_i params[:user][:type]=params[:user][:type].to_i neither work.. On Jan 3, 6:58 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Indeed > > On Jan 4, 2008 1:18 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > this would be in the controller in create and update then? > > > On Jan 3, 6:44pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > params[:user][:type].to_i > > > > All int''s submitted by fields are actually submitted as strings. Same > > goes > > > for dates and anything else, it''s always a string. > > > > On Jan 4, 2008 1:02 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > <%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, > > > > "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt > > > > =>true}) %> > > > > > produces: > > > > > <select id="user_type" name="user[type]"><option value="">Please > > > > select</option> > > > > <option value="3">Hygenist</option> > > > > <option value="4">Assistant</option> > > > > <option value="2">Doctor</option> > > > > <option value="1">Practice</option></select> </p> > > > > > and the form returns a string. how do i get the form to submit an > > > > int.. or get AR to convert it? select fields can return an int right? > > > > -- > > > Ryan Bigghttp://www.frozenplague.net > > > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text > > - > > > > - Show quoted text - > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
You want to do: @user.type = params[:user][:type].to_i @user.save! or something similiar. On Jan 3, 10:15 pm, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> forgive me I''m a newbie... > > I''ve tried both > > params[:user][:type].to_i > params[:user][:type]=params[:user][:type].to_i > > neither work.. > > On Jan 3, 6:58 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Indeed > > > On Jan 4, 2008 1:18 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > this would be in the controller in create and update then? > > > > On Jan 3, 6:44pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > params[:user][:type].to_i > > > > > All int''s submitted by fields are actually submitted as strings. Same > > > goes > > > > for dates and anything else, it''s always a string. > > > > > On Jan 4, 2008 1:02 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > <%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, > > > > > "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt > > > > > =>true}) %> > > > > > > produces: > > > > > > <select id="user_type" name="user[type]"><option value="">Please > > > > > select</option> > > > > > <option value="3">Hygenist</option> > > > > > <option value="4">Assistant</option> > > > > > <option value="2">Doctor</option> > > > > > <option value="1">Practice</option></select> </p> > > > > > > and the form returns a string. how do i get the form to submit an > > > > > int.. or get AR to convert it? select fields can return an int right? > > > > > -- > > > > Ryan Bigghttp://www.frozenplague.net > > > > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text > > > - > > > > > - Show quoted text - > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text - > > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
turns out :type must be used internal to AR.. I changed to :accounttype and updated the table and everything worked.. AR knew it was an INT and saved it correctly!! maybe a standard of prepending internal symbols with the classname would eliminate collitions On Jan 3, 7:15 pm, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> forgive me I''m a newbie... > > I''ve tried both > > params[:user][:type].to_i > params[:user][:type]=params[:user][:type].to_i > > neither work.. > > On Jan 3, 6:58 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Indeed > > > On Jan 4, 2008 1:18 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > this would be in the controller in create and update then? > > > > On Jan 3, 6:44pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > params[:user][:type].to_i > > > > > All int''s submitted by fields are actually submitted as strings. Same > > > goes > > > > for dates and anything else, it''s always a string. > > > > > On Jan 4, 2008 1:02 PM, spokra <spo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > <%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, > > > > > "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt > > > > > =>true}) %> > > > > > > produces: > > > > > > <select id="user_type" name="user[type]"><option value="">Please > > > > > select</option> > > > > > <option value="3">Hygenist</option> > > > > > <option value="4">Assistant</option> > > > > > <option value="2">Doctor</option> > > > > > <option value="1">Practice</option></select> </p> > > > > > > and the form returns a string. how do i get the form to submit an > > > > > int.. or get AR to convert it? select fields can return an int right? > > > > > -- > > > > Ryan Bigghttp://www.frozenplague.net > > > > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text > > > - > > > > > - Show quoted text - > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
On Jan 3, 2008, at 8:32 PM, spokra wrote:> > <%= select( "user" , "type", { "Practice" => 1, "Doctor" => 2, > "Hygenist" =>3, "Assistant" => 4 }, {:include_blank => false, :prompt > =>true}) %> > > produces: > > > <select id="user_type" name="user[type]"><option value="">Please > select</option> > <option value="3">Hygenist</option> > <option value="4">Assistant</option> > <option value="2">Doctor</option> > <option value="1">Practice</option></select> </p> > > > and the form returns a string. how do i get the form to submit an > int.. or get AR to convert it? select fields can return an int right?AR will know what to do with the string. The problem is that you''re using the word ''type.'' Change it to something else and it will work. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Damn it, I should''ve noticed. Yes type is a reserved field in ActiveRecord. It is used for putting types on Single Table Inheritance tables. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---