Forum: Ruby on Rails date_select intercept in model

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1aa74912806510a3aecd628c1dc8d62b?d=identicon&s=25 Simon (Guest)
on 2007-01-30 20:56
(Received via mailing list)
Hi there!

Currently im using date_select to select a day and month of the year.
But i'm hiding the year since it is not important. But when i try to
save to the database the controller complains that the year is
missing. Can i set the year to for example Time.now.year in the model?

date_select("timesheet", "date", :discard_year =>
true, :use_short_month => true)

Best regards,
Simon
6d57db44c5a4e0721cc7f78cf0ce308a?d=identicon&s=25 Stephen Bartholomew (steveb)
on 2007-01-30 21:20
(Received via mailing list)
Can you post the error message that you're receiving?

Steve
1aa74912806510a3aecd628c1dc8d62b?d=identicon&s=25 Simon (Guest)
on 2007-01-31 10:31
(Received via mailing list)
Hi, it seems that date(1i) is missing and that is why i get the error.
But i would like to set the year in the model and use create in the
controller instead of new where i can manually set the year.

 ActiveRecord::MultiparameterAssignmentErrors in
TimetrackController#create
1 error(s) on assignment of multiparameter attributes

Request
Parameters: {"commit"=>"Spara", "timesheet"=>{"time"=>"44",
"bc_project_id"=>"855290", "date(2i)"=>"1", "date(3i)"=>"31",
"description"=>"dfdfdf", "user_id"=>"1"}}
This topic is locked and can not be replied to.