move swag fields to partial

This commit is contained in:
nasia 2017-08-25 20:04:19 +03:00
parent 93f7e07ebe
commit e55509183c
5 changed files with 21 additions and 23 deletions

View file

@ -22,14 +22,12 @@
off_color: 'warning',
on_text: 'Yes',
off_text: 'No' }
- @sponsor.swag_hash.each do |type, quantity|
.row
.col-md-6
= f.input :type, label: 'Swag type'
.col-md-6
= f.input :quantity, as: :number, in: 0..9999
- generate_swags_hash(@type, @quantity)
= f.submit 'Add Swag', :type
- @sponsor.swag_hash.each_with_index do |k, v, index|
=render partial: 'swag_fields', locals: {f: f, index: index}
.row
.col-md-8
= image_tag f.object.picture.thumb.url if f.object.picture?

View file

@ -0,0 +1,5 @@
.row
.col-md-6
= text_field_tag "sponsor[swag_hash][#{index}][type]"
.col-md-6
= text_field_tag "sponsor[swag_hash][#{index}][quantity]"

View file

@ -1,7 +0,0 @@
<div class="swag_fields">
<%= f.inputs do %>
<%= f.input :type, label: 'Swags type' %>
<%= f.input :quantity, label: 'Swags quantity', as: :number, in: 0..9999 %>
<%- generate_swags_hash(@type, @quantity) %>
<% end %>
</div>