Forum: Ruby on Rails Strange bug in date_select?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Aa9467ff6b698dce20d0d7252e5a268f?d=identicon&s=25 Joram (Guest)
on 2007-03-15 12:07
(Received via mailing list)

I'm having a very strange error when using the date_select.

This is de code in my view:

<%= date_select :user, :birthdate , :order => [:day, :month, :year],
          :start_year =>, :end_year =>

This used in the expression user.update_attributes(params[:user])

So, nothing fancy here. But when I give in a date older than 1 january
1970, I get an error:
'1 error(s) on assignment of multiparameter attributes', which I don't
have with > 1970.
I checked the log, and both times the parameters are passed just fine.

Anyone has a clue?
5d60d4e28066df254d5452f92c910092?d=identicon&s=25 eric (Guest)
on 2007-03-15 12:34
Joram wrote:
> Anyone has a clue?

i use this:
<%= date_select :user, :birth , :order => [:day, :month, :year],
           :start_year => 1900, :end_year => 18.years.ago %>

and it works fine
28c315da59bc0bc0a544ed4a75ad26e9?d=identicon&s=25 Pierre-Alexandre Meyer (Guest)
on 2007-03-15 12:37
(Received via mailing list)
On Thu, Mar 15, 2007 at 04:07:14AM -0700, Joram wrote :
> So, nothing fancy here. But when I give in a date older than 1 january
> 1970, I get an error:
> '1 error(s) on assignment of multiparameter attributes', which I don't
> have with > 1970.

AR uses Time class and not DateTime. See
(11/17/05) for more informations about this topic.


| Pierre-Alexandre Meyer |
| email : |
Aa9467ff6b698dce20d0d7252e5a268f?d=identicon&s=25 Joram (Guest)
on 2007-03-15 15:09
(Received via mailing list)
Eric: I tried it, but it's still the same for me when I enter a date <

The 1970 should have made me realize it was a problem corresponnding
to the class where the time was stored.
I read your link, that's exactly what I need, but how can I apply the
patch suggested there?
B55f94832191b93f4f45f067aec465db?d=identicon&s=25 irfaniYangBaikHati (Guest)
on 2007-03-15 15:37
(Received via mailing list)
change the field type in your table to datetime

On 3/15/07, Joram <> wrote:
> > AR uses Time class and not DateTime.
> >


YM : irfani_s
Aa9467ff6b698dce20d0d7252e5a268f?d=identicon&s=25 Joram (Guest)
on 2007-03-15 15:47
(Received via mailing list)
It already is, unfortunately:

 create_table :users do |t|
      t.column 'username', :string, :null => false
      t.column 'name', :string
      t.column 'birthdate', :datetime

But thanks for your input!
88375bfc90530b2a8b918cbe93f43cf7?d=identicon&s=25 Simon (Guest)
on 2007-03-16 21:05

Did you sort this one out? I'm stuck with exactly the same issue.
88375bfc90530b2a8b918cbe93f43cf7?d=identicon&s=25 Simon (Guest)
on 2007-03-16 21:44
If you use a date datatype at least in sqlite3 and sqlserver, you should
be in good shape. Just remember that any calculations must be done with
the Date class.

change_column :users, :birthdate, :date

Also, you might find this handy

User's age in view:
<%=h (( - @user.date_of_birth)/365.25).round %>

Cheers, Simon
Aa9467ff6b698dce20d0d7252e5a268f?d=identicon&s=25 Joram Barrez (Guest)
on 2007-03-19 23:30
(Received via mailing list)
Hey Simon,

Sorry i didn't answer your mail, but I wasn't at home the past days.
I'm still having the problem at the moment, but I'll try your approach
and let you know if it worked (I'm not at my dev pc at the moment).

I already use your tip about the age, but I was wondering why you did
365.25 where I did 365.
After some thinking it struck me that I was forgotten about the leap
years! So thank you very much for the info!

Talk to you later!

Aa9467ff6b698dce20d0d7252e5a268f?d=identicon&s=25 Joram Barrez (Guest)
on 2007-03-23 15:54
(Received via mailing list)
Hello Simon,

Thanks for your advice, it works perfectly now (tested in MySQL 5) !

Should you ever be in Belgium, we'll have a drink ;-)

This topic is locked and can not be replied to.