First commit

This commit is contained in:
Vikram Rangnekar
2019-03-24 09:57:29 -04:00
commit b9d38a5e9d
153 changed files with 18120 additions and 0 deletions

View File

@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end

View File

View File

@ -0,0 +1,8 @@
class Customer < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :products, through: :purchases
end

View File

@ -0,0 +1,3 @@
class Product < ApplicationRecord
has_many :customers, through: :purchases
end

View File

@ -0,0 +1,4 @@
class Purchase < ApplicationRecord
validates :sale_type, :inclusion => { :in => %w{rented bought} }
validates :quantity, numericality: { greater_than: 0 }
end

View File

@ -0,0 +1,8 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :products
end