From a7c9181fc5b8b2194f47ec6cb808bc52cf08841d Mon Sep 17 00:00:00 2001 From: nilsding Date: Tue, 11 Nov 2014 18:09:28 +0100 Subject: [PATCH] fixed fuckups (again) --- app/controllers/ajax/inbox_controller.rb | 12 ++++-------- app/helpers/user_helper.rb | 4 ++-- app/views/inbox/show.html.haml | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/controllers/ajax/inbox_controller.rb b/app/controllers/ajax/inbox_controller.rb index 00541521..0f7dcc55 100644 --- a/app/controllers/ajax/inbox_controller.rb +++ b/app/controllers/ajax/inbox_controller.rb @@ -3,14 +3,6 @@ class Ajax::InboxController < ApplicationController params.require :id params.require :answer - question = Question.create!(content: params[:question], - author_is_anonymous: params[:anonymousQuestion], - user: current_user) - - unless current_user.nil? - current_user.increment! :answered_count - end - inbox = Inbox.find(params[:id]) unless current_user == inbox.user @@ -24,6 +16,10 @@ class Ajax::InboxController < ApplicationController user: current_user, question: inbox.question) + unless current_user.nil? + current_user.increment! :answered_count + end + Inbox.destroy inbox.id @status = :okay diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 1c5f57fb..68d8106e 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -1,8 +1,8 @@ module UserHelper # Decides what user name to show. # @return [String] The user name - def user_screen_name(user) - return APP_CONFIG['anonymous_name'] if user.nil? + def user_screen_name(user, anonymous=false) + return APP_CONFIG['anonymous_name'] if user.nil? || anonymous return user.display_name unless user.display_name.blank? user.screen_name end diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.html.haml index 674becdc..82ca5a89 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.html.haml @@ -3,7 +3,7 @@ .panel.inbox-box{'data-id' => i.id} %p %strong - = user_screen_name i.question.user + = user_screen_name i.question.user, i.question.author_is_anonymous asked: %p %strong