From b8df59d2ff8a990a0bcdb3703077765be2e757ba Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 19 Apr 2016 12:28:41 +0300 Subject: [PATCH] 117702653-csv_fix --- app/models/account_activity.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/account_activity.rb b/app/models/account_activity.rb index 3a0e7dc30..c6523be33 100644 --- a/app/models/account_activity.rb +++ b/app/models/account_activity.rb @@ -6,7 +6,6 @@ class AccountActivity < ActiveRecord::Base belongs_to :bank_transaction belongs_to :invoice - attr_accessor :registrar CREATE = 'create' RENEW = 'renew' @@ -24,14 +23,15 @@ class AccountActivity < ActiveRecord::Base end def to_csv - attributes = %w(registrar description activity_type created_at sum) + attributes = %w(description activity_type created_at sum) CSV.generate(headers: true) do |csv| csv << %w(registrar description activity_type receipt_date sum) all.each do |x| # rubocop:disable Rails/FindEach - x.registrar = Registrar.find(x.account_id).try(:code) - csv << attributes.map { |attr| x.send(attr) } + attrs = [x.account.registrar.try(:code)] + attrs += attributes.map { |attr| x.send(attr) } + csv << attrs end end end