fix for not displaying bulletin at fronted when it's parent category is disable

This commit is contained in:
Matthew K. Fu JuYuan committed 2012-07-11 17:17:44 +08:00
1 parent 98b274d9dd
commit ca2c056a07
10 files changed
+77 -10

No files matched your search

+30
View File
@@ -1,4 +1,34 @@
module OrbitCoreLib
module BelongsToCategoryMayDisable
def self.included(base)
base.instance_eval("belongs_to :#{base::BelongsToCategory.to_s}")
base.instance_eval("
scope :currently_available_by_category, lambda { |category|
check_data = category.to_a.collect{|cate| cate.id}
any_in(#{ base::BelongsToCategory.to_s}_id: check_data)
}
")
base.instance_eval("scope :admin_manager_all,find(:all)")
# base.instance_eval("scope :all,where(disable: false)")
base.instance_eval("
scope :all, lambda {
category = base::BelongsToCategory.to_s.classify.constantize.all
check_data = category.to_a.collect{|cate| cate.id}
any_in(#{ base::BelongsToCategory.to_s}_id: check_data)
}
")
base.class_eval("
def disable?
#{base::BelongsToCategory.to_s}.disable?
end
")
end
# end
end
module ObjectDisable
def self.included(base)