0
我已经成功解决该问题无不能强迫Fixnum对象,但我得到另一个:(错误,当我尝试去calendars_path(零不能强迫Fixnum对象)
没有给出块(产率)
我知道问题是上的index.html线8,但我不知道来解决它
模块CalendarHelper
def calendar(date = Date.today, &block)
Calendar.new(self, date, block).table
end
class Calendar < Struct.new(:view, :date, :callback)
HEADER = %w[Monday Mardi Mercredi jeudi Vendredi Samedi Dimanche]
START_DAY = :monday
delegate :content_tag, to: :view
def table
content_tag :table, class: "calendar" do
header + week_rows
end
end
def header
content_tag :tr do
HEADER.map { |day| content_tag :th, day }.join.html_safe
end
end
def week_rows
weeks.map do |week|
content_tag :tr do
week.map { |day| day_cell(day) }.join.html_safe
end
end.join.html_safe
end
def day_cell(day)
content_tag :td, view.capture(day, &callback), class: day_classes(day)
end
def day_classes(day)
classes = []
classes << "today" if day == Date.today
classes << "notmonth" if day.month != date.month
classes.empty? ? nil : classes.join(" ")
end
def weeks
first = date.beginning_of_month.beginning_of_week(START_DAY)
last = date.end_of_month.end_of_week(START_DAY)
(first..last).to_a.in_groups_of(7)
end
end
端
CONTROLER calendars_controller.rb
def index
@content_calendars = Calendar.all
@content_calendars_by_dates = @content_calendars.group_by(&:published_on)
@date = params[:date] ? Date.parse(params[:date]) : Date.today
end
def show
@calendar = Calendar.find(params[:id])
end
的index.html
1 <%= calendar @date do |date| %>
2 <%= date.day %>
3
4 <!--# <%= debug(params) if Rails.env.development? %>
5 --><% if @content_calendars_by_dates[date] %>
6 <ul>
7
8 <% @content_calendars_by_dates[date].each do |article| %>
9 <li><%= link_to calendar.event, article %></li>
10 <% end %>
11
12 </ul>
13 <% end %>
14 <% end %>
Ryans日历应用程序我已经成功地解决问题零不能强制进入Fixnum – zyriuse 2013-05-09 16:18:21
我遵循railscast的教程 – zyriuse 2013-05-09 16:26:34
我已经通过等待解决了我的问题。当我回来3个小时后,每个人都可以! – zyriuse 2013-05-12 18:59:15