请让我知道这些操作之间有什么区别。第一个代码工作正常:
1) for elem in(mr)
elem.shedule = Date.new(date.year, date.month, date.day)
end
但我想使用map
:
2) mr.map!{ |elem| elem.shedule = Date.new(date.year, date.month, date.day) }
第二个代码返回错误:
NoMethodError in Events#index
Showing C:/Sites/calend/app/views/events/_calendar.html.erb where line #9 raised:
undefined method `shedule' for Thu, 04 Apr 2013:Date
Extracted source (around line #9):
6: </h2>
7: <%= calendar_for(@repeats, :year => @date.year, :month => @date.month) do |calendar| %>
8: <%= calendar.head('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') %>
9: <%= calendar.day(:day_method => :shedule) do |date, events| %>
10: <%= date.day %> <%= link_to '+', new_event_path(date: date) %>
11: <ul>
12: <% for event in events %>