complete preview for both new and announcement

This commit is contained in:
Fu Matthew committed 2012-09-07 17:55:59 +08:00
1 parent 8bd5481b3f
commit 6044857fea
24 files changed
+301 -67

No files matched your search

+8 -8
View File
@@ -1,14 +1,14 @@
module OrbitCoreLib
module Preview
def self.included(base)
base.instance_eval("field :is_preview,type: Boolean,:default => false")
base.instance_eval("scope :not_preview,where(:is_preview=>false)")
base.define_singleton_method :new_preview do |*args|
temp_obj = self.new(args.first)
temp_obj.is_preview = true
temp_obj.save(:validate => false) rescue
temp_obj
end
# base.instance_eval("field :is_preview,type: Boolean,:default => false")
# base.instance_eval("scope :not_preview,where(:is_preview=>false)")
base.class_eval ("
def to_preview
raise 'Developer,please override to_preview method'
end
")
end
end