Remove nil hash objects

This commit is contained in:
nasia 2017-08-29 16:20:21 +03:00
parent 7cd1635317
commit 88a6b2769b
3 changed files with 41 additions and 36 deletions

View file

@ -9,12 +9,15 @@ module Admin
end
def show
@sponsor.swag.reject! { |_key, value| value[:type].blank? || value[:quantity].blank? }
@sponsor.swag_transportation.reject! { |_key, value| value[:carrier_name].blank? || value[:tracking_number].blank? || value[:boxes].blank? }
@sponsor.swag_index = @sponsor.swag.length
@sponsor.carrier_index = @sponsor.swag_transportation.length
end
def edit
@sponsor.swag = @sponsor.swag
@sponsor.swag.reject! { |_key, value| value[:type].blank? || value[:quantity].blank? }
@sponsor.swag_transportation.reject! { |_key, value| value[:carrier_name].blank? || value[:tracking_number].blank? }
@sponsor.swag_index = @sponsor.swag.length
@sponsor.carrier_index = @sponsor.swag_transportation.length
end

View file

@ -92,8 +92,9 @@
- else
%span.fa.fa-times.text-danger
%td
- if sponsor.has_swag
- if sponsor.swag.length > 0
- sponsor.swag.each do |key, value|
- unless value[:type].blank?
= value[:type]
(
= value[:quantity]
@ -163,7 +164,7 @@
= link_to 'Cancel', cancel_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
method: :patch, class: 'btn btn-mini btn-warning'
#to_contact.tab-pane
- if @conference.sponsors.to_contact.any?
- if @conference.sponsors.any?
.row
.col-md-12
%table.table.table-hover#sponsors
@ -175,7 +176,8 @@
%th Level
%th Actions
%tbody
- @conference.sponsors.to_contact.each do |sponsor|
- @conference.sponsors.each do |sponsor|
- if sponsor.state =='to_contact'
%tr
%td
= image_tag(sponsor.picture.thumb.url, width: '20%')
@ -197,7 +199,7 @@
= link_to 'Confirm', confirm_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
method: :patch, class: 'btn btn-mini btn-success'
- if sponsor.transition_possible? :contact
= link_to 'Contacted', contact_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
= link_to 'Mark as Contacted', contact_admin_conference_sponsor_path(@conference.short_title, sponsor.id),
method: :patch, class: 'btn btn-mini btn-default'
- if sponsor.transition_possible? :cancel
= link_to 'Cancel', cancel_admin_conference_sponsor_path(@conference.short_title, sponsor.id),

View file

@ -74,7 +74,7 @@
off_text: 'No' }
- if @sponsor.has_swag
- if @sponsor.swag.length > 0
%tr
%td.col-md-2
%b Swag's Type