Class: Api::AnswersController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Api::AnswersController
- Defined in:
- app/controllers/api/answers_controller.rb
Instance Method Summary collapse
Methods included from Response
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/api/answers_controller.rb', line 8 def create answer = Answer.new(answer_params) if answer.save render json: answer, status: :created else render json: answer.errors., status: :unprocessable_entity end end |
#destroy ⇒ Object
18 19 20 21 22 |
# File 'app/controllers/api/answers_controller.rb', line 18 def destroy @answer.destroy render status: :ok end |
#update ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/controllers/api/answers_controller.rb', line 24 def update if @answer.update(answer_params) render @answer, status: :ok else render json: @answer.errors., status: :unprocessable_entity end end |