Swags stored correctly

This commit is contained in:
nasia 2017-08-26 20:41:36 +03:00
parent 2042d0eb7a
commit 4381f687b6
7 changed files with 18 additions and 28 deletions

View file

@ -22,10 +22,9 @@
off_color: 'warning',
on_text: 'Yes',
off_text: 'No' }
- @sponsor.swag_hash.each_with_index do |hash, index|
=render partial: 'swag_fields', locals: {f: f, index: index}
=render partial: 'swag_fields', locals: { f: f, index: @sponsor.swag_index}
- @sponsor.swags.each_with_index do |(key, value), index|
=render partial: 'swag_fields', locals: {f: f, index: index, v_type: value[:type].to_s, v_quantity: value[:quantity].to_i}
=render partial: 'swag_fields', locals: { f: f, index: @sponsor.swag_index, v_type: nil, v_quantity: 0}
.row
.col-md-8

View file

@ -1,5 +1,5 @@
.row
.col-md-6
= f.input :type, label: 'Swag\'s type', input_html: { name: "sponsor[swag_hash][#{index}][type]"}
= f.input :type, label: 'Swag\'s type', input_html: { name: "sponsor[swags][#{index}][type]", value: v_type }
.col-md-6
= f.input :quantity, input_html: { name: "sponsor[swag_hash][#{index}][quantity]"}
= f.input :quantity, as: :number, in: 0...999, input_html: { name: "sponsor[swags][#{index}][quantity]", value: v_quantity}

View file

@ -69,12 +69,12 @@
%b Swag's Type
%td
%b Quantity
%tr
- @sponsor.swag_hash.each do |key, value|
- @sponsor.swags.each do |key, value|
%tr
%td.col-md-2
= key
= value[:type]
%td
= value
= value[:quantity]