Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Event < ActiveRecord::Base
- scope :before, lambda {|end_time| {:conditions => ["ends_at < ?", Event.format_date(end_time)] }}
- scope :after, lambda {|start_time| {:conditions => ["starts_at > ?", Event.format_date(start_time)] }}
- def self.format_date(date_time)
- Time.at(date_time.to_i).to_formatted_s(:db)
- end
- def as_json(options = {})
- {
- :id => self.id,
- :title => self.title,
- :description => self.description || "",
- :start => starts_at.rfc822,
- :end => ends_at.rfc822,
- :allDay => self.all_day,
- :recurring => false,
- :url => Rails.application.routes.url_helpers.event_path(id),
- :color => "red",
- :backgroundColor => "red",
- :borderColor => "black",
- :textColor => "white"
- }
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement