Rails - list of years in HAML search form
How can I have a开发者_开发知识库 search form have a list of years?
Parameters:
- Rails3
- Is not tied to a database object
- Should use current year and have a range of -20 years to current year.
- Should not use a date-picker. I just want the year.
- Should be in HAML
select_tag "year", options_for_select(((Date.today.year - 20)..Date.today.year).to_a)
<%= select_tag "year", ((Date.today.year-20)..Date.today.year).map{|year| "<option>#{year}</option>"}.join.html_safe %>
We worked on this for a bit and (I also use HAML) the answer (I have accepted it) was
= select_tag "year", ((Date.today.year-20)..Date.today.year).map{|year| "<option>#{year}</option>".html_safe}
精彩评论