added suppliers, weight to item
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
class Cart < ActiveRecord::Base
|
||||
|
||||
has_many :item_in_carts
|
||||
belongs_to :user
|
||||
|
||||
end
|
||||
|
||||
@@ -2,6 +2,9 @@ class Item < ActiveRecord::Base
|
||||
belongs_to :unit
|
||||
has_many :multi_media_descriptions
|
||||
belongs_to :sub_category
|
||||
belongs_to :supplier
|
||||
|
||||
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id, :weight, :supplier_id
|
||||
|
||||
|
||||
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id
|
||||
end
|
||||
|
||||
@@ -5,4 +5,8 @@ class ItemInCart < ActiveRecord::Base
|
||||
validates_uniqueness_of :item_id, scope: :cart_id
|
||||
validates :item_id, presence: true
|
||||
validates :cart_id, presence: true
|
||||
|
||||
def to_s
|
||||
item.name + " " + count.to_s + " " + price.to_s
|
||||
end
|
||||
end
|
||||
|
||||
6
back-office/app/models/supplier.rb
Normal file
6
back-office/app/models/supplier.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Supplier < ActiveRecord::Base
|
||||
has_many :items
|
||||
|
||||
validates_uniqueness_of :name
|
||||
validates_presence_of :name
|
||||
end
|
||||
10
back-office/app/models/user.rb
Normal file
10
back-office/app/models/user.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class User < ActiveRecord::Base
|
||||
has_many :carts
|
||||
|
||||
validates_presence_of :first_name, :last_name, :password, :email, :password_confirmation
|
||||
|
||||
validates :email, :uniqueness => {:case_sensitive => false, :message => "Email already exists!"},
|
||||
format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, message: "invalid email" }
|
||||
|
||||
validates :password, confirmation: true, length: { in:6..20, too_short: 'password needs to be at least 6 characters long' }
|
||||
end
|
||||
Reference in New Issue
Block a user