Commit b810f251 by ivan Lan

Improve join_catalog_system with a new option :validate_name_chain

parent 60799c69
...@@ -4,4 +4,3 @@ json.extract! product, :id, :title, :status, :status_zh, ...@@ -4,4 +4,3 @@ json.extract! product, :id, :title, :status, :status_zh,
# TODO: NOTE: catalog_list is only vaild in the template example # TODO: NOTE: catalog_list is only vaild in the template example
json.catalog_list product.catalog_list if product.respond_to?(:catalog_list) json.catalog_list product.catalog_list if product.respond_to?(:catalog_list)
json.default_series product.default_series, partial: 'shotengai/share/series_simple', as: :series json.default_series product.default_series, partial: 'shotengai/share/series_simple', as: :series
json.series product.series, partial: 'shotengai/share/series_simple', as: :series
\ No newline at end of file
...@@ -107,9 +107,10 @@ module Shotengai ...@@ -107,9 +107,10 @@ module Shotengai
catalog_class = catalog_class_name.constantize catalog_class = catalog_class_name.constantize
tag_name = options[:as] || catalog_class.model_name.singular tag_name = options[:as] || catalog_class.model_name.singular
acts_as_taggable_on tag_name.to_sym acts_as_taggable_on tag_name.to_sym
# set { validate_name_chain: false } to skip the validate_name_chain
# 只有完整替换(只属于一个分类)的时候才进行验证,add remove 暂时未添加 # 只有完整替换(只属于一个分类)的时候才进行验证,add remove 暂时未添加
# Just catalogs_list= have a validation # Just catalogs_list= have a validation
class_eval do options[:validate_name_chain].eql?(false) || class_eval do
define_method("#{tag_name}_list=") { |value| define_method("#{tag_name}_list=") { |value|
super catalog_class.validate_name_chain(value) super catalog_class.validate_name_chain(value)
} }
......
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