Advertisement
Guest User

Untitled

a guest
Jan 13th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.74 KB | None | 0 0
  1. class Event < ActiveRecord::Base
  2.  
  3.   scope :before, lambda {|end_time| {:conditions => ["ends_at < ?", Event.format_date(end_time)] }}
  4.   scope :after, lambda {|start_time| {:conditions => ["starts_at > ?", Event.format_date(start_time)] }}
  5.  
  6.   def self.format_date(date_time)
  7.    Time.at(date_time.to_i).to_formatted_s(:db)
  8.   end
  9.  
  10.   def as_json(options = {})
  11.   {
  12.   :id => self.id,
  13.   :title => self.title,
  14.   :description => self.description || "",
  15.   :start => starts_at.rfc822,
  16.   :end => ends_at.rfc822,
  17.   :allDay => self.all_day,
  18.   :recurring => false,
  19.   :url => Rails.application.routes.url_helpers.event_path(id),
  20.   :color => "red",
  21.   :backgroundColor => "red",
  22.   :borderColor => "black",
  23.   :textColor  => "white"
  24.   }
  25.   end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement