Permalink
Browse files

implemented delete payment

  • Loading branch information...
1 parent 09d1f1f commit cb193c76b76ecf68e924adb08dba3673a54f458b @marutanm committed Feb 9, 2012
Showing with 12 additions and 3 deletions.
  1. +5 −0 app/controllers.rb
  2. +5 −1 app/javascripts/application.coffee
  3. +2 −2 app/views/list.haml
View
@@ -15,4 +15,9 @@
redirect ''
end
+ post '/delete/:id' do
+ Payment.find(params[:id]).delete
+ current_budget.update_total
+ end
+
end
@@ -1,2 +1,6 @@
$ ->
- console.log 'coffee'
+ $('.trash').each ->
+ $(@).click ->
+ id = $(@).attr('payment_id')
+ $.post "/delete/#{$(@).attr('payment_id')}", =>
+ $("##{id}").remove()
View
@@ -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.