Created
March 7, 2012 07:23
-
-
Save fadhlirahim/1991616 to your computer and use it in GitHub Desktop.
rails return json for fullcalendar.js dates displays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Model | |
class Meeting < ActiveRecord::Base | |
scope :date_range, lambda {|*args| where("start_date between ? and ?", args.first, args.last) } | |
end | |
#Controller | |
# fullcalendar.js dates displays | |
def meeting_dates | |
start_range = params[:start].present? ? Time.at(params[:start].to_i) : Date.civil(Time.now.year, Time.now.month, 1) | |
end_range = params[:end].present? ? Time.at(params[:end].to_i) : Date.civil(Time.now.year, Time.now.month, -1) | |
@meetings = Meeting.date_range(start_range, end_range).by_account(current_account.id) | |
respond_to do |format| | |
format.json { render :json => @meetings} | |
format.html | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment