This commit is contained in:
Yan
2017-10-23 13:31:02 +06:30
parent dfa3a4c08f
commit 4adfa48d75

View File

@@ -67,4 +67,24 @@ class SeedGenerator < ApplicationRecord
next_code = prefix + seed.current.to_s.to_s.rjust((count)+1,'0')
return next_code
end
def self.update_seed(model, current, inc)
cur_val = 0
next_val = 0
nex = current + inc
update_sql = "update seed_generators set current= #{current}, next= #{nex} where model='#{model}';";
select_sql = "select * from seed_generators where model='#{model}';"
update_result = ActiveRecord::Base.connection.execute(update_sql);
select_result = ActiveRecord::Base.connection.execute(select_sql);
select_result.each do |row|
p row
cur_val = row [3]
next_val = row[4]
end
return cur_val, next_val
end
end