diff --git a/app/assets/javascripts/spa.js b/app/assets/javascripts/spa.js index 2920c10..154ce6c 100644 --- a/app/assets/javascripts/spa.js +++ b/app/assets/javascripts/spa.js @@ -30,4 +30,19 @@ app.controller('TransgressionsController', ['$http', function($http){ }); }); } + + this.createConfession = function(transgression_id){ + var csrf = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); + $http.post('/transgressions/'+transgression_id+'/confessions', { + authenticity_token: csrf, + confession: { + occurred_at: this.newConfessionDate, + description: this.newConfessionDescription + } + }).success(function(data){ + $http.get('/transgressions').success(function(data){ + controller.transgressions = data.transgressions; + }); + }); + } }]); diff --git a/app/views/spa.html.erb b/app/views/spa.html.erb index 4b7937f..147d1c3 100644 --- a/app/views/spa.html.erb +++ b/app/views/spa.html.erb @@ -17,10 +17,18 @@ Description: {{transgression.description}}
Created: {{transgression.authored_at}} -
+

Moments of Glory

+ +

When was your soul last weak?

- - + +