Class: Voluntary::Api::V1::BrainstormingIdeaVotesController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Voluntary::Api::V1::BrainstormingIdeaVotesController
- Includes:
- V1::BaseController
- Defined in:
- app/controllers/voluntary/api/v1/brainstorming_idea_votes_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/voluntary/api/v1/brainstorming_idea_votes_controller.rb', line 13 def create resource = current_user.brainstorming_idea_votes.create idea_id: params[:idea_id] respond_to do |format| format.json do render json: resource.persisted? ? resource : { errors: resource.errors.to_hash } end end end |
#destroy ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/voluntary/api/v1/brainstorming_idea_votes_controller.rb', line 23 def destroy resource = current_user.brainstorming_idea_votes.where(idea_id: params[:idea_id]).first raise ActiveRecord::RecordNotFound unless resource resource.destroy if resource.persisted? raise I18n.t('activerecord.errors.models.brainstorming_idea_vote.attributes.base.deletion_failed') end respond_to do |format| format.json do render json: {} end end end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/voluntary/api/v1/brainstorming_idea_votes_controller.rb', line 6 def index idea = BrainstormingIdea.friendly.find params[:idea_id] respond_with do |format| format.json { render json: idea.votes.includes(:user) } end end |