Skip to content

Instantly share code, notes, and snippets.

View puneetpandey's full-sized avatar
🏠
Working Remotely

Puneet Pandey puneetpandey

🏠
Working Remotely
View GitHub Profile
require 'rubygems'
require 'viewpoint' # Library for MS Outlook
require 'viewpoint/logging/config' # For Debugging
include Viewpoint::EWS
endpoint = 'YOUR MS EXACHANGE URL COMES HERE' # E.g. https://OUTLOOKSERVER_URL/ews/exchange.asmx
user = 'USERNAME'
pass = 'PASSWORD'
cli = Viewpoint::EWSClient.new endpoint, user, pass
# app/models
class User < ActiveRecord::Base
has_many :responses, dependent: :destroy
end
class Response < ActiveRecord::Base
has_one :report
has_many :points
belongs_to :user
end
class Product < ActiveRecord::Base
has_many :suppliers, conditions: ["suppliers.status = ?", true]
end
# In Rails4, if you wish to use the same, you can use the below syntax:
class Product < ActiveRecord::Base
has_many :suppliers, -> { where("suppliers.status = ?", true) }
end
#{PATH_TO_APP}$ rails g model Person name:string email:string
#{PATH_TO_APP}$ rails g model Community name:string description:text
class Person < ActiveRecord::Base
has_and_belongs_to_many :communities
end
class Community < ActiveRecord::Base
has_and_belongs_to_many :persons
end