app/controllers/binda/choices_controller.rb in binda-0.1.3 vs app/controllers/binda/choices_controller.rb in binda-0.1.4
- old
+ new
@@ -1,19 +1,22 @@
require_dependency "binda/application_controller"
module Binda
- class ChoicesController < ApplicationController
+ class ChoicesController < ApplicationController
- before_action :set_choice
+ before_action :set_choice
- def destroy
- @choice.destroy
- head :ok
- end
+ def destroy
+ if @choice.destroy
+ head :ok
+ else
+ render json: { errors: @choice.errors.full_messages }, status: 500
+ end
+ end
- private
+ private
- def set_choice
- @choice = Choice.find( params[:id] )
- end
- end
+ def set_choice
+ @choice = Choice.find( params[:id] )
+ end
+ end
end
\ No newline at end of file