My favorites
▼
|
Sign in
substruct
Open-source Ruby on Rails E-Commerce
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
12
attachment: variation.rb
(992 bytes)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Holds information about how the product varies.
#
class Variation < Item
belongs_to :product
#############################################################################
# CALLBACKS
#############################################################################
after_save :update_parent_quantity
def update_parent_quantity
self.product.update_attribute('variation_quantity', self.product.variations.sum('quantity'))
end
#############################################################################
# CLASS METHODS
#############################################################################
# References parent product images collection.
#
def images
self.product.images
end
# Display name...includes product name as well
def name
if self.product
return "#{self.product.name} - #{self.attributes['name']}"
else
return self.attributes['name']
end
end
def short_name
self.attributes['name']
end
end
Powered by
Google Project Hosting