November 17, 201114 yr Hi, I set up a model, controller and view without a scaffold and now having trouble converting text_field strings into integers. I have a form for creating a new object like below. <% form_for(@person) do |f| %> <%= f.error_messages %> <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> <p> <%= f.label :number_test %><br /> <%= f.text_field :number_test %> </p> <p> <%= f.submit 'Create' %> </p> <% end %> However clicking create comes back with errors relating to attempting to add a string to the number_test variable which is an integer. Does anyone know how to take the text_field input as a integer before assigning it to the number_test variable. I am using JRuby 1.5.0 with Rails 2.3.4 Thanks
November 17, 201114 yr Author It okay, figured it out, had the variable name wrong, it actual converts it automatically for you
Create an account or sign in to comment