Sha256: d1f93bc3f343810a5bce4a118cdaaef64c3c27f66e70f042e40cb93e28209e1a

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module Answers
  class Api::V1::TaggingsController < Answers::Api::V1::ApiController
    respond_to :json

    def index
      taggings = ActsAsTaggableOn::Tagging.all
      render locals: {taggings: taggings}
    end

    def show
      puts "SHOW!!!"
      tagging = ActsAsTaggableOn::Tagging.find(params[:id])
      render locals: {tagging: tagging}
    end
  
    def create
      tagging = ActsAsTaggableOn::Tagging.new(tagging_params)
      tagging.save
      render 'tagging/show', locals: {tag: tagging}
    end

    def update
      tag = ActsAsTaggableOn::Tagging.find(params[:id])
      tag.update(tag_params)
      render 'tagging/show', locals: {tagging: tagging}
    end

    def destroy
      tagging = ActsAsTaggableOn::Tagging.find(params[:id])
      tagging.destroy
      render 'tagging/show', locals: {tagging: tagging}
    end

    private
      def tagging_params
        params.require(:tagging).permit(
          :tag_id,
          :taggable_id,
          :taggable_type,
          :tagger_id,
          :tagger_type,
          :context
        )
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
answers-core-0.0.0.2 app/controllers/answers/api/v1/taggings_controller.rb
answers-core-0.0.0 app/controllers/answers/api/v1/taggings_controller.rb