class Image include Mongoid::Document include Mongoid::Timestamps field :html_id field :html_class field :in_css, :type => Boolean, :default => false field :in_html, :type => Boolean, :default => false field :name mount_uploader :file, ImageUploader belongs_to :design before_save :set_name protected def set_name self.name = self.file_identifier end end