I'm using calendar_helper with success using this code:
<%=
calendar({:year => Date.today.year, :month => Date.today.month}) do |d|
cell_text = "#{d.mday}"
cell_attrs = {:class => 'day'}
@events.each do |e|
if e.start_at.mday == d.mday
cell_text << link_to开发者_如何学Python( e.name, :action => 'show', :id => e ) << "<br />"
cell_attrs[:class] = 'specialDay'
end
end
[cell_text, cell_attrs]
end
%>
This gives me the correct html, with events falling on this month's days being outputed correctly. However, this gives me the escaped code, so i need to pass it trough raw.
As soon as i pass it trough raw though, i lose the details on the calendar (events) and get only the calendar itself.
Any idea why this is happening or how to circumvent it?
I put the work I needed to do in a helper method and passed day and my collection (like your @events) to the helper method. It worked fine without a call to raw and left the view code much cleaner.
精彩评论