piggybak_variants 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ module PiggybakVariantsHelper
|
|
10
10
|
def variant_map(object)
|
11
11
|
map = {}
|
12
12
|
object.variants.available.each do |variant|
|
13
|
-
map[variant.option_values.
|
13
|
+
map[variant.option_values.hash_ordered.map { |ov| ov.id }.join('_')] = { :id => variant.piggybak_sellable.id, :price => number_to_currency(variant.piggybak_sellable.price) }
|
14
14
|
end
|
15
15
|
map.to_json
|
16
16
|
end
|
@@ -6,7 +6,8 @@ module PiggybakVariants
|
|
6
6
|
has_and_belongs_to_many :variants
|
7
7
|
belongs_to :option, :inverse_of => :option_values
|
8
8
|
|
9
|
-
scope :ordered, :
|
9
|
+
scope :ordered, :order => "position ASC"
|
10
|
+
scope :hash_ordered, :include => :option, :order => "options.position ASC, option_values.position ASC"
|
10
11
|
|
11
12
|
def admin_label
|
12
13
|
"#{self.option.name}: #{self.name}"
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<% options_for_klass(object.class).each do |option| -%>
|
10
10
|
<div class="option" id="option_<%= option.id %>">
|
11
11
|
<h4><%= option.name %></h4>
|
12
|
-
<% option.option_values.each do |option_value| -%>
|
12
|
+
<% option.option_values.ordered.each do |option_value| -%>
|
13
13
|
<input type="radio" name="option_<%= option.id %>" value="<%= option_value.id %>" />
|
14
14
|
<%= option_value.name %><br />
|
15
15
|
<% end -%>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piggybak_variants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
segments:
|
104
104
|
- 0
|
105
|
-
hash:
|
105
|
+
hash: 2273664173460174425
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
segments:
|
113
113
|
- 0
|
114
|
-
hash:
|
114
|
+
hash: 2273664173460174425
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
117
|
rubygems_version: 1.8.23
|