orbit-4-2/app/models/category.rb

38 lines
891 B
Ruby
Raw Permalink Normal View History

class Category
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Authorizable
field :disable, type: Boolean, default: false
field :title, localize: true
field :custom, type: Boolean, default: false
field :custom_value
validates :title, :at_least_one => true
belongs_to :module_app
has_many :buffer_categories
scope :enabled, where(:disable.in => [false, nil, ''])
end
# base.instance_eval("scope :admin_manager_all,find(:all)")
# base.define_singleton_method :find do |*args|
# if args ==[:all]
# unscoped
# else
# res = unscoped.find(args)
# res.count == 1 ? res[0] : res
# end
# end
# base.define_singleton_method :first do |*args|
# all.first
# end
# base.define_singleton_method :last do |*args|
# all.last
# end