Class: MechanizeStore::Product

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mechanize_store/product.rb

Instance Method Summary collapse

Instance Method Details

#create_slugObject



20
21
22
# File 'app/models/mechanize_store/product.rb', line 20

def create_slug
  self.update_attributes(:slug => "#{self.id}-#{self.name.parameterize}")
end

#first_photoObject



11
12
13
14
# File 'app/models/mechanize_store/product.rb', line 11

def first_photo
    return nil if self.product_photos.empty?
    return self.product_photos.first
end

#set_defaultsObject



16
17
18
# File 'app/models/mechanize_store/product.rb', line 16

def set_defaults
  self.slug = "#{self.id}-#{self.name.parameterize}"
end