Using calendar helper to jump to other months

Hello,

I have the following in my controller to display a calendar using
calendar helper:

if not request.post?
  @year = Time.now.year
  @month = Time.now.month
else
  @year = Date.new(params[:date][:year], Time.now.month.to_s,

Time.now.mday.to_s).year # this is line 154
@month = Date.new(Time.now.year.to_s,params[:date][:month],
Time.now.mday.to_s).month
end

This is what I have in the corresponding view:

Ship Calendar

<%= start_form_tag %>
<%= select_month(Date.today)%>
<%= select_year(Date.today)%>
<%= submit_tag ‘Go’ %>
<%= end_form_tag %>

<%=
calendar({:year => @year, :month => @month}) do |d|
cell_text = “#{d.mday}

cell_attrs = {:class => ‘day’}

@sales_orders.each do |o|
if o.ship_date.month == d.month
if o.ship_date.mday == d.mday

      cell_text << link_to( o.id.to_s, :controller =>

‘sales_orders’, :action => ‘show’, :id => o ) << “

cell_attrs[:class] = ‘specialDay’
end
end
end
[cell_text, cell_attrs]
end
%>

I can view the calendar initially, since it defaults to the current
month. But when I change the select box’s month and submit it, I get
the following error:

comparison of String with 0 failed
#{RAILS_ROOT}/app/controllers/histories_controller.rb:154:in
`history_calendar’

What am I doing wrong? I’m just trying to be able to switch to
different months for the calendar.

Thanks,

Jason

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs