On 7 August 2010 02:40, Chad Weier <[email protected]> wrote:
> Hi, real newbie question.
>
> How come this wont save to the database!
>
>         <%= select(:to_time_unit, 'id', @time.timearray) %>
>
> to_time_unit is the column is the database that is to hold the selected
> time unit.
> 'id' is just somethign I made up I dont know whether it is relevant
>
> @time.timearray gets a method from the model that lists an array of
> times
> -second
> -minute
> -hour
>
> However when I submit my form that holds this select field, it does not
> save it to the database, it enters null into the database.

I presume you are using form_tag as you are using select rather than
f.select.  You would probably be better to use
form_for though there is no reason why it should not work with
form_tag and select.

Have a look at the generated html of the page (view, page source or
similar in the browser) and make sure it is what you expect.  Make
sure that you understand the html that you see there.

Then look in development.log to see what params are being passed to
your action on submit.  Again make sure that you understand what you
see there.

Look at your code to see what you are doing with the params.  Once
again make sure you understand the code if you have pasted it from a
tutorial or it has been generated by scaffold.

If still no clues use ruby-debug to break into the action in your
controller and see what is happening.  See Rails Guide on debugging if
you do not know how to do this.

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to