Re: Saving dates

askegg
2006-12-19T04:44:24Z

That is the correct usage, but your controller is trying to pull the
date submitted apart and force it into the database.
Since the date fields are named with the database field name you can
just use:

  Exhibition.create(params[:details])

instead of:

  @exhibition.open_date = params[:details][:open_date]
  @exhibition.save

If you want some error checking, you might want to try something like:

  @exhibition = Exhibition.new(params[:details])
  if @exhibition.save
    flash[:notice] = "Exhibition created"
    redirect_to :action => :index and return


On Dec 19, 3:03 pm, Stewart
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
> askegg wrote:
> > I think Alan is right.  Rails is expected a date, but you are passing
> > it an array.
>
> > Use date_select in your form instead of an array of values.
> >
(http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html...)I
think i already am...
>
> here is my code anyway.
>
>
>
>     Date the exhibition opens:
>
>
>
>   <%= date_select("details", "open_date") %>
>
>     *Required
>
>
>
>
>     Date the exhibition closes:
>
>
>
>   <%= date_select("details", "close_date") %>
>
>     *Required
>
>
>
> am i used date_select in the correct way?
>
> --
> Posted viahttp://www.ruby-forum.com/.