Commit 935fe548 by ivan Lan

Use :shotengai_product instead of :product in series.rb

parent bb12b081
......@@ -58,11 +58,11 @@ module Shotengai
# where("spec->'$.\"颜色\"' = ? and spec->'$.\"大小\"' = ?" ,红色,S)
scope :query_spec_value_with_product, ->(val, product, eql: true) {
if val.keys.sort == product.spec_template.keys.sort || (eql.! && (val.keys - product.spec_template.keys).empty?)
if val.keys.sort == shotengai_product.spec_template.keys.sort || (eql.! && (val.keys - shotengai_product.spec_template.keys).empty?)
keys = []; values = [];
proc = Proc.new { |k, v| keys << "spec_value->'$.\"#{k}\"' = ? "; values << v }
Shotengai::Harray === val ? val.hash_map(&proc) : val.map(&proc)
where(product: product).where(keys.join(' and '), *values)
where(product: shotengai_product).where(keys.join(' and '), *values)
else
self.none
end
......@@ -137,7 +137,7 @@ module Shotengai
end
def uniq_spec_value
if self.class.query_spec_value_with_product(self.spec_value, self.product).alive.where.not(id: self.id).any?
if self.class.query_spec_value_with_product(self.spec_value, self.shotengai_product).alive.where.not(id: self.id).any?
errors.add(:spec_value, 'Non uniq spec_value for the product.')
end
end
......@@ -148,7 +148,7 @@ module Shotengai
def check_remark_value
# product.remark_value.keys 包含 remark_value.keys
illegal_key = (remark_value.keys - product.remark_template&.keys)
illegal_key = (remark_value.keys - shotengai_product.remark_template&.keys)
errors.add(:remark_value, "非法的关键字, #{illegal_key}") unless illegal_key.empty?
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment