2015-09-23 11:09:24 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: barcodes
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# product_id :integer
|
|
|
|
# code :string default(""), not null
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
#
|
|
|
|
|
|
|
|
class Barcode < ActiveRecord::Base
|
2015-09-28 21:51:40 +02:00
|
|
|
include FriendlyId
|
|
|
|
friendly_id :code, use: :finders
|
|
|
|
|
2015-09-23 11:09:24 +02:00
|
|
|
belongs_to :product
|
|
|
|
|
2015-10-28 21:54:55 +01:00
|
|
|
validates :product, presence: true
|
2015-09-25 14:24:32 +02:00
|
|
|
validates :code, presence: true, uniqueness: true
|
2015-09-23 11:09:24 +02:00
|
|
|
end
|