Orbit/app/models/design/design.rb

43 lines
1.3 KiB
Ruby
Raw Normal View History

class Design
include Mongoid::Document
include Mongoid::Timestamps
include ParserLayout
field :author, :type => String
field :intro, :type => String
2012-10-24 10:40:38 +00:00
field :title, :type => String
field :version, :type => String
mount_uploader :zip_file, AssetUploader
2012-11-05 15:04:54 +00:00
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
2012-10-24 10:40:38 +00:00
has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy
has_one :thumb, :autosave => true, :dependent => :destroy
2012-11-20 02:04:50 +00:00
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
2012-11-05 15:04:54 +00:00
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_many :pages
has_many :screenshots, :autosave => true, :dependent => :destroy
has_many :themes, :autosave => true, :dependent => :destroy
2012-10-24 10:40:38 +00:00
accepts_nested_attributes_for :images, :allow_destroy => true
accepts_nested_attributes_for :javascripts, :allow_destroy => true
accepts_nested_attributes_for :screenshots, :allow_destroy => true
2012-10-24 10:40:38 +00:00
accepts_nested_attributes_for :themes, :allow_destroy => true
validates_presence_of :author, :title
2012-02-24 11:11:51 +00:00
after_save :parse_css_for_images
protected
def parse_css_for_images
2012-10-24 10:40:38 +00:00
self.css_default.parse_urls
self.themes.each do |theme|
2012-10-24 10:40:38 +00:00
theme.parse_urls
end
parse_body_for_images(self)
end
end