register_modules/app/models/registered_desktop_widget.rb

25 lines
653 B
Ruby

class RegisteredDesktopWidget
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCategory::Categorizable
include OrbitTag::Taggable
include Slug
field :name, as: :slug_title, localize: true
field :widget_key
field :create_user_id, type: BSON::ObjectId
field :update_user_id, type: BSON::ObjectId
field :approved, type: Boolean, :default => false
scope :approve, ->{ where(approved: true) }
mount_uploader :widget, TemplateUploader
mount_uploader :icon, ImageUploader
after_create :save_widget_key
def save_widget_key
self.widget_key = self.name.parameterize + "-" + self.uid
self.save
end
end