This commit is contained in:
parent
c107aafa5f
commit
8479f308ac
2
Rakefile
2
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue