asking questions is now possible! …kinda.
This commit is contained in:
parent
9fad73341e
commit
ba71902c27
|
@ -0,0 +1,16 @@
|
|||
class Ajax::QuestionController < ApplicationController
|
||||
def create
|
||||
params.require :question
|
||||
params.require :anonymousQuestion
|
||||
params.require :rcpt
|
||||
|
||||
|
||||
|
||||
Question.create(content: params[:question],
|
||||
author_is_anonymous: params[:anonymousQuestion])
|
||||
|
||||
@status = :okay
|
||||
@message = "Question asked successfully."
|
||||
@success = true
|
||||
end
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
class AjaxController < ApplicationController
|
||||
def ask
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
json.partial! 'ajax/shared/status'
|
|
@ -24,7 +24,7 @@ Rails.application.routes.draw do
|
|||
match '/settings/profile', to: 'user#update', via: 'patch', as: :update_user_profile
|
||||
|
||||
namespace :ajax do
|
||||
match '/ask', to: 'ajax#ask', via: :post, as: :ask
|
||||
match '/ask', to: 'question#create', via: :post, as: :ask
|
||||
end
|
||||
|
||||
match '/user/:username', to: 'user#show', via: 'get'
|
||||
|
|
Loading…
Reference in New Issue