lib/html_helpers.rb
# A select tag that allows to select a year
A select tag that allows to select a year
A select tag that allows to select a year
def select_year(name:, value:, css_class:'form-control')
    require 'date'
    current_year=DateTime.now.year
    options=(1900..current_year).map {|y| "<option value='#{y}' #{(value.to_i==y) ? "selected='selected'":''}>#{y}</option>"}.join("\n")
    "<select name='#{name}' class='#{css_class}'> #{options}</select>"
  end
def select_year ( name : , value : , css_class : 'form-control' ) require 'date' current_year = DateTime . now . year options = ( 1900 .. current_year ) . map { | y | "<option value='#{y}' #{(value.to_i==y) ? "selected='selected'":''}>#{y}</option>" } . join ( "\n" ) "<select name='#{name}' class='#{css_class}'> #{options}</select>" end
A select tag that allows to select a year
A select tag that allows to select a year
name
value
css_class