Improve the demo experience
This commit is contained in:
3
rails-app/app/models/application_record.rb
Normal file
3
rails-app/app/models/application_record.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
0
rails-app/app/models/concerns/.keep
Normal file
0
rails-app/app/models/concerns/.keep
Normal file
8
rails-app/app/models/customer.rb
Normal file
8
rails-app/app/models/customer.rb
Normal 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
|
3
rails-app/app/models/product.rb
Normal file
3
rails-app/app/models/product.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class Product < ApplicationRecord
|
||||
has_many :customers, through: :purchases
|
||||
end
|
4
rails-app/app/models/purchase.rb
Normal file
4
rails-app/app/models/purchase.rb
Normal file
@ -0,0 +1,4 @@
|
||||
class Purchase < ApplicationRecord
|
||||
validates :sale_type, :inclusion => { :in => %w{rented bought} }
|
||||
validates :quantity, numericality: { greater_than: 0 }
|
||||
end
|
8
rails-app/app/models/user.rb
Normal file
8
rails-app/app/models/user.rb
Normal 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
|
Reference in New Issue
Block a user