25 lines
679 B
Ruby
25 lines
679 B
Ruby
|
class Desktop
|
||
|
include Mongoid::Document
|
||
|
include Mongoid::Timestamps
|
||
|
|
||
|
field :theme
|
||
|
field :customtheme
|
||
|
field :wallpaper
|
||
|
|
||
|
belongs_to :user
|
||
|
has_and_belongs_to_many :desktop_widgets, :autosave => true
|
||
|
|
||
|
has_many :sections, :autosave => true, :dependent => :destroy
|
||
|
has_many :desktop_wallpapers, :autosave => true, :dependent => :destroy
|
||
|
# has_many :desktop_widgets, :autosave => true, :dependent => :destroy
|
||
|
|
||
|
before_create :initialize_section
|
||
|
|
||
|
def initialize_section
|
||
|
self.sections.build(name: "Desktop 1")
|
||
|
self.sections.build(name: "Desktop 2")
|
||
|
self.sections.build(name: "Desktop 3")
|
||
|
self.sections.build(name: "Desktop 4")
|
||
|
end
|
||
|
|
||
|
end
|