Retrospring/app/controllers/ajax/question_controller.rb

22 lines
656 B
Ruby
Raw Normal View History

class Ajax::QuestionController < ApplicationController
def create
params.require :question
params.require :anonymousQuestion
params.require :rcpt
question = Question.create!(content: params[:question],
author_is_anonymous: params[:anonymousQuestion],
2014-11-10 22:08:59 -08:00
user: current_user)
2014-11-10 22:18:34 -08:00
unless current_user.nil?
current_user.increment! :asked_count unless params[:anonymousQuestion] == 'true'
end
Inbox.create!(user_id: params[:rcpt], question_id: question.id, new: true)
@status = :okay
@message = "Question asked successfully."
@success = true
end
end