From fa96e8423918adda076abfa964bb9a5bc3eb5029 Mon Sep 17 00:00:00 2001 From: nilsding Date: Tue, 11 Nov 2014 06:51:56 +0100 Subject: [PATCH] the user who asked is now stored in the question --- app/controllers/ajax/question_controller.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/ajax/question_controller.rb b/app/controllers/ajax/question_controller.rb index 6269e945..3a2917e0 100644 --- a/app/controllers/ajax/question_controller.rb +++ b/app/controllers/ajax/question_controller.rb @@ -4,8 +4,15 @@ class Ajax::QuestionController < ApplicationController params.require :anonymousQuestion params.require :rcpt + user = unless user_signed_in? + current_user + else + nil + end + question = Question.create!(content: params[:question], - author_is_anonymous: params[:anonymousQuestion]) + author_is_anonymous: params[:anonymousQuestion], + user: user) Inbox.create!(user_id: params[:rcpt], question_id: question.id, new: true)