mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-23 03:07:50 +01:00
asking questions is now possible! …kinda.
This commit is contained in:
parent
9fad73341e
commit
ba71902c27
5 changed files with 18 additions and 5 deletions
16
app/controllers/ajax/question_controller.rb
Normal file
16
app/controllers/ajax/question_controller.rb
Normal file
|
@ -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
|
|
1
app/views/ajax/question/create.json.jbuilder
Normal file
1
app/views/ajax/question/create.json.jbuilder
Normal file
|
@ -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
|
match '/settings/profile', to: 'user#update', via: 'patch', as: :update_user_profile
|
||||||
|
|
||||||
namespace :ajax do
|
namespace :ajax do
|
||||||
match '/ask', to: 'ajax#ask', via: :post, as: :ask
|
match '/ask', to: 'question#create', via: :post, as: :ask
|
||||||
end
|
end
|
||||||
|
|
||||||
match '/user/:username', to: 'user#show', via: 'get'
|
match '/user/:username', to: 'user#show', via: 'get'
|
||||||
|
|
Loading…
Reference in a new issue