Skip to content

Instantly share code, notes, and snippets.

Created November 12, 2012 22:15
Show Gist options
  • Save anonymous/4062341 to your computer and use it in GitHub Desktop.
Save anonymous/4062341 to your computer and use it in GitHub Desktop.
$('#nextmonth').click(fuction(e)) {
$.get('/rota_days/show.json?mon=12').success(function(data) {
$('#nextmonth').on('click', fuction(e)) {
$.get('/rota_days/show.json?mon=12').success(function(data) {
for ( i = 0; i < rota_days.length; i++)
{
rota_days = data
}
});
});
});
<table class = "rota">
<thead>
<th>Date</th>
<% @hospitals.each do |hosp| %>
<th><%= hosp.name%></th>
<% end %>
</thead>
<tbody>
<% @dates.each do |date| %>
<tr>
<td><%= date.to_s(:short) %></td>
<% ([email protected]).each do %>
<td></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<%= link_to 'Next Month', rota_days_path(:month => 12), :remote => true %>
class RotaDaysController < ApplicationController
# GET /rota_days
# GET /rota_days.json
# load_and_authorize_resource
respond_to :json, :html
def index
@rota_days = RotaDay.all
# @dates = @rota_days.collect(&:day)
@hospitals = Hospital.all
t1 = Date.today.at_beginning_of_month
t2 = Date.today.end_of_month
@dates = (t1..t2).to_a
@title = "Rota"
respond_to do |format|
format.html # index.html.erb
format.json { render json: @rota_days }
end
end
def nextmonth
@rota_days = RotaDay.all
respond_with(@rota_days)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment