开发者

calendar_helper cannot be used with raw()

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜