class Customer < ApplicationRecord #self.primary_key = :customer_id before_create :generate_custom_id has_many :orders has_many :sales validates_presence_of :name, :contact_no, :email validates :contact_no, uniqueness: true validates :email, uniqueness: true def self.get_member_group gateway_url = MembershipSetting.find_by_membership_type("smartpay_url") url = gateway_url.gateway_url.to_s + "/api/get_all_member_group".to_s response = HTTParty.get(url) puts response.body, response.code, response.message, response.headers.inspect return response; end # http://192.168.1.47:3006/api/create_membership_customer #get_all_member_group 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