From 8479f308ac9dee06faa577674b864f1000aeef5f Mon Sep 17 00:00:00 2001 From: nilsding Date: Sun, 7 Dec 2014 14:29:35 +0100 Subject: [PATCH] ! --- Rakefile | 2 ++ app/models/user.rb | 6 +----- config/routes.rb | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 81e44f66..6cd625f1 100644 --- a/Rakefile +++ b/Rakefile @@ -32,6 +32,8 @@ namespace :justask do Answer.all.each do |answer| begin smiles = Smile.where(answer: answer).count + comments = Comment.where(answer: answer).count + answer.comment_count = comments answer.smile_count = smiles answer.save! end diff --git a/app/models/user.rb b/app/models/user.rb index 850ebb4a..b9a5617a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -102,12 +102,8 @@ class User < ActiveRecord::Base end def comment(answer, content) - Comment.create(user: self, answer: answer, content: content) + Comment.create!(user: self, answer: answer, content: content) increment! :commented_count answer.increment! :comment_count end - - def destroy_comment(comment) - # TODO: implement this - end end diff --git a/config/routes.rb b/config/routes.rb index bdf443be..374a663d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,6 +33,7 @@ Rails.application.routes.draw do match '/destroy_friend', to: 'friend#destroy', via: :post, as: :destroy_friend match '/create_smile', to: 'smile#create', via: :post, as: :create_smile match '/destroy_smile', to: 'smile#destroy', via: :post, as: :destroy_smile + match '/create_comment', to: 'comment#create', via: :post, as: :create_comment end match '/inbox', to: 'inbox#show', via: 'get'