I'm using a table builder
https://github.com/p8/table_builder
for a calendar that I found in this Rails cast:
http://railscasts.com/episodes/213-calendars.
My problem is that by default, the calendar is presented by month but I want to present it by week. Does anyone know how to customize the calendar's display?
this is my calendar view:
<div id="calendar">
<h2 id="month">
<%= link_to "<", :month => (@date.beginning_of_month-1).strftime("%Y-%m-%d") %>
<%=h @date.strftime("%B %Y") %>
<%= link_to ">", :month => (@date.end_of_month+1).strftime("%Y-%m-%d") %>
</h2>
<% calendar_for @statuses, :year => @date.year, :month => @date.month do |calendar| %>
<%= calendar.head('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') %>
<% calendar.day(:day_method => :date) do |date, statuses| %>
<%= date.day %>
<ul>
<% for status in statuses %>
<li><%= link_to h(status.content), status %></li>
<% end %>
</ul>
<% end %>
<% end %>
</div>
and this is the controller:
class CalendarController < ApplicationController
def index
do_withs = DoWith.where(:friend_id => current_user.id)
@statuses = do_withs.collect { |f| f.status_id }
@statuses = @statuses.collect { |f| Status.find(f) }
@statuses = @statuses + current_user.statuses
@statuses.flatten!
@date = params[:month] ? Date.parse(params[:month]) : Date.today
end
end
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…