Skip to content

Instantly share code, notes, and snippets.

@davejachimiak
Created June 27, 2012 14:36
Show Gist options
  • Save davejachimiak/3004454 to your computer and use it in GitHub Desktop.
Save davejachimiak/3004454 to your computer and use it in GitHub Desktop.
Cohabitant and Notification models
class Cohabitant < ActiveRecord::Base
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates_presence_of :department, :location, :contact_name, :contact_email
validates :contact_email, :format => { :with => VALID_EMAIL_REGEX }
has_and_belongs_to_many :notifications
end
class Notification < ActiveRecord::Base
belongs_to :user
has_and_belongs_to_many :cohabitants
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment