rails-app moved to examples folder

This commit is contained in:
Siva M
2019-10-02 22:49:58 -04:00
parent 0fc1236266
commit e68bdffa25
120 changed files with 8 additions and 282 deletions

View File

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

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