Improve the demo experience

This commit is contained in:
Vikram Rangnekar
2019-04-11 01:10:51 -04:00
parent 512647156e
commit 40fb85c926
125 changed files with 50 additions and 60 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