Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many years options to be built

After upgrading from Rails 3.0x to 3.2.11 I got the following error:

There're too many years options to be built. Are you sure you haven't mistyped something? You can provide the :max_years_allowed parameter

Code:

<%= f.date_select :to,
    :start_year => Time.now.year - 80,
    :discard_day => true,
    :include_blank => true %>

I've also tried to include a :max_years_allowed parameter without success, how do I fix this?

like image 290
hso Avatar asked Oct 05 '22 22:10

hso


1 Answers

According to the rails docs the select_year method in date_select sets max_years_allowed to 1000 if the option isn't passed in. It then looks to see if the absolute value of the ending year minus the starting year is greater than the max_years_allowed option. Have you opened up the rails console and checked that Time.now.year - 80 isn't giving a year more than 1000 years ago? I know it sounds crazy, but it's about the only reason I could see you getting that error.

Here's the link.

like image 54
jmcharnes Avatar answered Oct 13 '22 11:10

jmcharnes