1

I'm using similar code to Railscast 213 to display a calendar with records.

The do line is causing a "getting wrong number of arguments (1 for 0):

<%= calendar @date do |date| %>
    <%= date.day %>
    <% if @wolabors_by_date[date] %>
      <ul>
        <% @wolabors_by_date[date].each do |wolabor| %>
          <li><%= link_to wolabor.name, wolabor %></li>
        <% end %>
      </ul>
    <% end %>   
<% end %>

The calendar_helper.rb starts out with:

module CalendarHelper
    def calendar(date = Date.today, &block)
        Calendar.new(self, date, block).table   
    end

wolabors_controller.rb has

class WolaborsController <     ApplicationController
def index
  @wolabors = Wolabor.all
  @wolabors_by_date = @wolabors.group_by(&:date)
  @date = params[:date] ? Date.parse(params[:date]) : Date.today
end`
Reddirt
  • 5,913
  • 9
  • 48
  • 126
  • what line is giving you the error? – Baconator507 Dec 10 '12 at 21:41
  • <%= calendar @date do |date| %> – Reddirt Dec 10 '12 at 21:44
  • ok then I think the correct method is calendar_for – Baconator507 Dec 10 '12 at 21:46
  • Could you post your @date definition in the controller index action ? I've found in the discussion about this Railscast , that the statement :first = date.beginning_of_month.beginning_of_week(START_DAY) gives the same arguments error . These methods are Rails 3.2 specific and if you are on lower version , you should upgrade . – R Milushev Dec 10 '12 at 23:52
  • I just put the @date def in the original question – Reddirt Dec 11 '12 at 00:13
  • I'm using 3.1.3 - I'll upgrade - thanks!!! – Reddirt Dec 11 '12 at 00:19
  • I hope everything is Ok now . If you have solved the problem , just tell us . – R Milushev Dec 11 '12 at 12:36
  • I have never upgraded Rails app before. I'm upgrading this app from 3.1.3 to 3.2.8 -- and I'm running into issues with gems that are locking me at certain levels. But, that's a different issue. Thanks for the help! Qumara - if you enter your answer about the versions, I will accept it. – Reddirt Dec 11 '12 at 15:17

2 Answers2

0

I think that first line is supposed to be

<% calendar_for @date do |date| %>

That railscast has been revised and it does not use that table_builder plugin in the new version.

http://railscasts.com/episodes/213-calendars-revised

Baconator507
  • 1,747
  • 2
  • 12
  • 20
0

I've found in the discussion about this Railscast , that the statement :

first = date.beginning_of_month.beginning_of_week(START_DAY) 

gives the same arguments error . It seems methods

beginning_of_month

and

beginning_of_week

are Rails 3.2 specific and if you are on lower version , you should upgrade.

R Milushev
  • 4,295
  • 3
  • 27
  • 35