Sha256: ac63ebd226244d0b8e3e565ee6215b8c34c1efe5b35546973442baa35d668e36
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
class Voluntary::Api::V1::BrainstormingIdeaVotesController < ActionController::Base include Voluntary::V1::BaseController respond_to :json def index idea = BrainstormingIdea.friendly.find params[:idea_id] respond_with do |format| format.json { render json: idea.votes.includes(:user) } end end 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 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
voluntary_brainstorming-0.0.2 | app/controllers/voluntary/api/v1/brainstorming_idea_votes_controller.rb |