Topic: Dates

Hi having trouble saving dates in my form i have the following in the
view

<%= date_select("details", "open_date") %>

and i have

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

and then

@exhibition.save

All the other values form (not seen here) get saved but not the dates they are just null in the database.
What am i doing wrong ?

oh here is my schema before you ask wink

#  id                :integer(11)   not null, primary key
#  name              :string(255)   
#  subtitle          :string(255)   
#  short_description :string(255)   
#  description       :string(255)   
#  curator           :string(255)   
#  artists           :string(255)   
#  url               :string(255)   
#  image             :string(255)   default(/exhibition/image/1_0.gif)
#  catalogue         :string(255)   
#  admission_price   :text         
#  open_date         :date         
#  close_date        :date         
#  user_id           :integer(11)   
#  gallery_id        :integer(11)

Re: Dates

Can you post the rest of the code? How are you updating the other attributes? Perhaps something is overriding the date.

Or maybe the date is only parsed properly when doing mass assignment:

@exhibition.update_attributes(params[:details])

Railscasts - Free Ruby on Rails Screencasts

Re: Dates

yea that was it you have to use

@exhibition = Exhibition.new(params[:details])

you cant pass them in one by one like i was.

Thanks for that ryan