app/controllers/tags_controller.rb
class TagsController < ApplicationController
# GET /tags
# GET /tags.json
def index
@tags = Tag.all
respond_to do |format|
format.json { render json: @tags }
end
end
# GET /tags/1
# GET /tags/1.json
def show
@tag = Tag.find(params[:id])
respond_to do |format|
format.json { render json: @tag }
end
end
# GET /tags/new
# GET /tags/new.json
def new
@tag = Tag.new
respond_to do |format|
format.json { render json: @tag }
end
end
# POST /tags
# POST /tags.json
def create
@tag = Tag.new(params[:tag])
respond_to do |format|
if @tag.save
format.json { render json: @tag, status: :created, location: @tag }
else
format.json { render json: @tag.errors, status: :unprocessable_entity }
end
end
end
# PUT /tags/1
# PUT /tags/1.json
def update
@tag = Tag.find(params[:id])
respond_to do |format|
if @tag.update_attributes(params[:tag])
format.json { head :no_content }
else
format.json { render json: @tag.errors, status: :unprocessable_entity }
end
end
end
# DELETE /tags/1
# DELETE /tags/1.json
def destroy
@tag = Tag.find(params[:id])
@tag.destroy
respond_to do |format|
format.json { no_content_as_json }
end
end
end