app/controllers/api/tags_controller.rb
# create a new tag record with parameters
create a new tag record with parameters
create a new tag record with parameters
def create
    @tag = Tag.new tag_params
    @tag.admin = current_user
    if @tag.save
      render :show, status: 200
    elsif @tag.errors.messages[:value].include? 'has already been taken' 
      render json: { error: '409 conflict with existing record' }, status: 409
    else
      render json: { error: '422 unprocessable entity' }, status: 422
    end
  end
def create @tag = Tag . new tag_params @tag . admin = current_user if @tag . save render :show , status : 200 elsif @tag . errors . messages [ :value ] . include? 'has already been taken' render json : { error : '409 conflict with existing record' } , status : 409 else render json : { error : '422 unprocessable entity' } , status : 422 end end
create a new tag record with parameters
create a new tag record with parameters
# there's probably a better way to do this