Form 'select' question

Hi, I'd like to make a select element in a form which has the names of
months for the user to select, but sends numeric values for each month
when the form is submitted.

At the moment I have something like this:

<%= select_tag(:month, options_for_select(%w{ 1 2 3 4 5 6 7 8 9 },
@params[:month])) %>

But I'd like it to display the month names instead of the numbers. Any


Ok, I've figured out how to do that, so ignore that last message, but I
now have another harder problem! The calendar I'm using displays the
current month when the page is loaded and the month can be changed
using the select element. However I can't get the select element to
show the current month when the page loads. This is my controller code:

class CalendarController < ApplicationController

  before_filter :year, :month

  def index
    if @params[:month] == nil && (@params[:year]) == nil
      @params[:month] = @month
      @params[:year] = @year


  def year
    @year =

  def month
    @month =


And my view template:

        calendar(:year => @params[:year].to_i, :month =>
@params[:month].to_i, :first_day_of_week => 1) do |d|
          link_to d.mday, :action => 'day_detail', :id => d.mday

      <%= form_tag(:action => :index) %>

        <%= select_tag(:month, options_for_select([["Jan", "1"], ["Feb",
"2"], ["Mar", "3"], ["Apr", "4"], ["May", "5"], ["Jun", "6"], ["Jul",
"7"], ["Aug", "8"], ["Sep", "9"], ["Oct", "10"], ["Nov", "11"], ["Dec",
"12"]], @params[:month])) %>
        <%= select_tag(:year, options_for_select(%w{ 2006 2007 },
@params[:year])) %>
        <%= submit_tag("Ok") %>

      <%= end_form_tag %>

      <%= @params[:year] %>
      <%= @params[:month] %>


@params[:month] is set to the current month if there has been nothing
sent to it by the form. The calendar displays the correct month, as
does <%= @params[:month] %> at the bottom. Why does my select list not
showw the correct month?


Have you thought about using one of the Rails built in functions?