2013-03-01 01:16:04 +00:00
|
|
|
class MappingsController < ApplicationController
|
2014-07-27 19:57:35 +00:00
|
|
|
|
|
|
|
before_filter :require_user, only: [:create, :update, :destroy]
|
|
|
|
|
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
# GET /mappings/1.json
|
|
|
|
def show
|
|
|
|
@mapping = Mapping.find(params[:id])
|
2013-03-01 00:56:27 +00:00
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
render json: @mapping
|
2013-03-01 00:56:27 +00:00
|
|
|
end
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
# POST /mappings.json
|
2013-03-01 00:56:27 +00:00
|
|
|
def create
|
2014-07-27 19:57:35 +00:00
|
|
|
@mapping = Mapping.new(params[:mapping])
|
2013-03-01 01:56:57 +00:00
|
|
|
|
2014-10-07 23:11:55 +00:00
|
|
|
@mapping.map.touch(:updated_at)
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
if @mapping.save
|
|
|
|
render json: @mapping, status: :created
|
|
|
|
else
|
|
|
|
render json: @mapping.errors, status: :unprocessable_entity
|
2013-03-01 00:56:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
# PUT /mappings/1.json
|
2013-03-01 00:56:27 +00:00
|
|
|
def update
|
2014-07-27 19:57:35 +00:00
|
|
|
@mapping = Mapping.find(params[:id])
|
|
|
|
|
2014-10-07 23:11:55 +00:00
|
|
|
@mapping.map.touch(:updated_at)
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
if @mapping.update_attributes(params[:mapping])
|
|
|
|
head :no_content
|
|
|
|
else
|
|
|
|
render json: @mapping.errors, status: :unprocessable_entity
|
|
|
|
end
|
2013-03-01 00:56:27 +00:00
|
|
|
end
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
# DELETE /mappings/1.json
|
2013-03-01 00:56:27 +00:00
|
|
|
def destroy
|
2014-07-27 19:57:35 +00:00
|
|
|
@mapping = Mapping.find(params[:id])
|
2014-10-07 23:11:55 +00:00
|
|
|
@map = @mapping.map
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
@mapping.destroy
|
|
|
|
|
2014-10-07 23:11:55 +00:00
|
|
|
@map.touch(:updated_at)
|
|
|
|
|
2014-07-27 19:57:35 +00:00
|
|
|
head :no_content
|
2013-03-01 00:56:27 +00:00
|
|
|
end
|
2014-10-07 23:11:55 +00:00
|
|
|
end
|