Skip to content

Commit

Permalink
implemented delete payment
Browse files Browse the repository at this point in the history
  • Loading branch information
marutanm committed Feb 9, 2012
1 parent 09d1f1f commit cb193c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/controllers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@
redirect ''
end

post '/delete/:id' do
Payment.find(params[:id]).delete
current_budget.update_total
end

end
6 changes: 5 additions & 1 deletion app/javascripts/application.coffee
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
$ ->
console.log 'coffee'
$('.trash').each ->
$(@).click ->
id = $(@).attr('payment_id')
$.post "/delete/#{$(@).attr('payment_id')}", =>
$("##{id}").remove()
4 changes: 2 additions & 2 deletions app/views/list.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
%h4= CONFIG[genre]
%tbody
- budget.payments.where(genre: genre).each do |payment|
%tr
%tr{:id => payment.id}
-# .span1= "#{payment.created_at.strftime("%d %a")}"
%td= payment.title
%td.price
- if now - payment.created_at < 1.hours
%span.label.label-important
%span.label.label-important.trash{:payment_id => payment.id}
%i.icon-trash.icon-white
= payment.price

0 comments on commit cb193c7

Please sign in to comment.