custom primary key for transaction
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
class Customer < ApplicationRecord
|
||||
before_create :generate_custom_id
|
||||
has_many :orders
|
||||
has_many :sales
|
||||
|
||||
@@ -8,4 +9,9 @@ class Customer < ApplicationRecord
|
||||
def lastest_invoices
|
||||
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user