Open hasyrails opened 4 years ago
jsとかややこしいの使わずRailsでカスタム自由度の高いカレンダー実装
で、次に@calendar_daysに突っ込む値です
@calendar_daysはどうすれば良いの?? となった
def index
@calendar_days = get_calendar_dates(Date.today)
end
## 以下、参考そのまま
def get_calendar_dates(date)
‥
end
def get_pre_shortage_days(date)
‥
end
def get_post_shortage_days(date)
‥
end
参考そのまま
<div class="event-calendar">
<table>
<caption>2016年9月</caption>
<tbody>
<tr>
<th>日</th>
<th>月</th>
<th>火</th>
<th>水</th>
<th>木</th>
<th>金</th>
<th>土</th>
</tr>
<% @calendar_days.each_with_index do |day, i| %>
<% if i == 0 || i % 7 == 0 %>
<tr>
<% end %>
<td>
<p>
<%= day %>
</p>
<div>
<!-- ここにカレンダー1日単位で情報埋める -->
</div>
</td>
<% if i != 0 && (i + 1) % 7 == 0 %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
Rails.application.routes.draw do
+ resources :calendar
end
カレンダーを表示させる
実装参考 jsとかややこしいの使わずRailsでカスタム自由度の高いカレンダー実装