I''m not sure what you''re after here, but I''ll take a
stab at it.
Are you confused because the values of the options are not 2 digits (ie:
1 instead of 01, and so on)? This is not an issue, rails will handle the
insert correctly and the date format in the database will be 0000-00-00,
as expected.
Are you confused about the square bracket in front of the
cerecruit[sdate] variable name? It is because you passed in an empty
string to the first parameter of date_select. I think what you want is,
in your controller, to have an instance variable named @cerecruits and
your view whould have this:
<td>
<%= date_select("cerecruit", "sdate",:use_month_numbers
=> true)%>
</td>
In your database, you have a table similar to this (maybe some other
fields):
create table cerecruits (
id int auto_increment not null,
sdate date,
primary key (id)
);
Your model:
class Cerecruit < ActiveRecord::Base
end
In your controller, something like this:
def new
@cerecruit = cerecruit.new
end
def save #assuming save creates a new record
@cerecruit = Cerecruit(@params[''cerecruit''])
@cerecruit.save
end
Everything will just automagically work for you.
Here''s hoping this is what you were after. Good luck.
Pratik Mehta wrote:> Hi,
>
> I am trying to setup a form where i could use the date helper and then it
would input the date value in to a mysql db with type date (format of the date
is: 0000-00-00).
>
> Here is my views/new.rhtml for date
> <td>
> <%= date_select("",
"cerecruit[sdate]",:use_month_numbers => true)%>
>
> </td>
>
> and when i call it up on the web browser it shows up as:
>
> <td>Session Date</td>
> <td>
> <select name="[cerecruit[sdate](1i)]">
> <option>2000</option>
> <option>2001</option>
> .....
> </select>
>
> <select name="[cerecruit[sdate](2i)]">
> <option value="1">1</option>
> <option value="2">
> .........
> </select>
> <select name="[cerecruit[sdate](3i)]">
> <option>1</option>
> <option>2</option>
> ...... and so on....
>
> How would i code in the controller when the date will be in the format
0000-00-00 ?
>
> Thanks in advance for any help.
>
> - Pratik
>
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails