How do I use select_year with form_for? How do I use select_year with form_for? ruby-on-rails ruby-on-rails

How do I use select_year with form_for?


select_year is a helper that generates a full select tag with options. Since you're using form_for instead of form_tag, you'll want to use a helper that can be called on a form builder object.

<%= f.select :model_year, (Time.zone.now.year - 100)..(Time.zone.now.year + 1) %>

Reference: http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-select_year