Skip to content

Instantly share code, notes, and snippets.

@glideranderson
Created May 16, 2012 21:45
Show Gist options
  • Save glideranderson/2714214 to your computer and use it in GitHub Desktop.
Save glideranderson/2714214 to your computer and use it in GitHub Desktop.
Horrible rails controller method, need help
[{:active=>"no", :start=>Tue, 15 May 2012 20:42:17 UTC +00:00, :amount=>"10.00", :card_type=>"Visa", :card_number=>"0195"}]
<p>Get this output at the end of my .each</p>
def get_payment_history
history = Array.new
@payments.each do |p|
response = Rails.application.config.payment_gateway.status_recurring(p.profile_id)
if response.success?
history << {
:active => (response.params['profile_status'] == 'ActiveProfile') ? 'yes' : 'no',
:start => p.created_at, #response.params['billing_start_date'],
:amount => response.params['amount'],
:card_type => response.params['credit_card_type'],
:card_number => response.params['credit_card_number']
}
end
end
return history
end
= @history.each do |h|
.row
.three.columns
= h[:active]
.three.columns
= h[:start].strftime("%b %d, %Y")
.two.columns
= h[:amount]
.two.columns
= h[:card_type]
.two.columns
= h[:card_number]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment