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
end
end
private
def year
@year = Time.now.year
end
def month
@month = Time.now.month
end
end
///////////////////////////////////////////////////////////
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
end
%>
<%= 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?
Thanks