# Select method save to database

**URL:** <https://www.ruby-forum.com/t/select-method-save-to-database/192861>\
**Category:** Rails\
**Created:** [August 7, 2010, 3:40am UTC](https://www.ruby-forum.com/t/select-method-save-to-database/192861 "2010-08-07T03:40:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![superwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@superwick](https://www.ruby-forum.com/u/superwick)\
**Post date:** [August 7, 2010, 3:40am UTC](https://www.ruby-forum.com/t/select-method-save-to-database/192861/1 "2010-08-07T03:40:12Z")

</div>

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.

What am I doing wrong please help me!

---

<div class="post-metadata">

**Author:** ![superwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@superwick](https://www.ruby-forum.com/u/superwick)\
**Post date:** [August 7, 2010, 9:56am UTC](https://www.ruby-forum.com/t/select-method-save-to-database/192861/2 "2010-08-07T09:56:44Z")

</div>

On 7 August 2010 02:40, Chad W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> @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

---

<div class="post-metadata">

**Author:** ![superwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@superwick](https://www.ruby-forum.com/u/superwick)\
**Post date:** [August 7, 2010, 5:28pm UTC](https://www.ruby-forum.com/t/select-method-save-to-database/192861/3 "2010-08-07T17:28:03Z")

</div>

please help me ,what problem is going on there…

C:\InstantRails-2.0-win\_2\rails\_apps\store\>rake db:migrate  
(in C:/InstantRails-2.0-win\_2/rails\_apps/store)  
rake aborted!  
syntax error on line 4, col 2: ` database: store\_development’

(See full trace by running task with --trace)

---

<div class="post-metadata">

**Author:** ![superwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@superwick](https://www.ruby-forum.com/u/superwick)\
**Post date:** [August 7, 2010, 5:32pm UTC](https://www.ruby-forum.com/t/select-method-save-to-database/192861/4 "2010-08-07T17:32:09Z")

</div>

please help me ,what problem is going on there…

mane od database is “store\_development”

C:\InstantRails-2.0-win\_2\rails\_apps\store\>rake db:migrate  
(in C:/InstantRails-2.0-win\_2/rails\_apps/store)  
rake aborted!  
syntax error on line 4, col 2: ` database: store\_development’

(See full trace by running task with --trace)

---

<div class="post-metadata">

**Author:** ![superwick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@superwick](https://www.ruby-forum.com/u/superwick)\
**Post date:** [August 7, 2010, 5:38pm UTC](https://www.ruby-forum.com/t/select-method-save-to-database/192861/5 "2010-08-07T17:38:00Z")

</div>

On 7 August 2010 06:55, pravin mishra [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> please help me ,what problem is going on there…
> 
> C:\InstantRails-2.0-win\_2\rails\_apps\store\>rake db:migrate  
> (in C:/InstantRails-2.0-win\_2/rails\_apps/store)  
> rake aborted!  
> syntax error on line 4, col 2: ` database: store\_development’
> 
> (See full trace by running task with --trace)

What has this got to do with the subject line? (Select method save to  
database). Please start a new thread for this question. Please then  
post the whole of the file in question (presumably database.yml) and  
the full error message. When you get a syntax error look on lines  
immediately above also in case it is caused by the lines before.

Colin
