Hi, 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 => Time.now.year-120, :end_year => Time.now.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?
on 2007-03-15 13:07
on 2007-03-15 13: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
on 2007-03-15 13:37
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 http://wiki.rubyonrails.org/rails/pages/OlderQuest... (11/17/05) for more informations about this topic. ++ -- ,========================. | Pierre-Alexandre M. | | email : email@example.com | `========================'
on 2007-03-15 16:09
Eric: I tried it, but it's still the same for me when I enter a date < 1970 Pierre-Alexandre: 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?
on 2007-03-15 16:37
change the field type in your table to datetime On 3/15/07, Joram <firstname.lastname@example.org> wrote: > > > AR uses Time class and not DateTime. > > > > > -- irfani YM : irfani_s http://irfani.web.id
on 2007-03-15 16:47
It already is, unfortunately: create_table :users do |t| t.column 'username', :string, :null => false t.column 'name', :string t.column 'birthdate', :datetime end But thanks for your input!
on 2007-03-16 22:05
Joram, Did you sort this one out? I'm stuck with exactly the same issue.
on 2007-03-16 22: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 ((Date.today - @user.date_of_birth)/365.25).round %> Cheers, Simon
on 2007-03-20 00:30
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! Joram
on 2007-03-23 16:54
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 ;-) Joram