これらの操作の違いを教えてください。最初のコードは正常に動作します:
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) }
2 番目のコードはエラーを返します。
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 %>