pundit: make it work
This commit is contained in:
parent
4ed00240eb
commit
cb79f2deae
1 changed files with 6 additions and 6 deletions
|
@ -9,7 +9,7 @@ class MappingsController < ApplicationController
|
||||||
# GET /mappings/1.json
|
# GET /mappings/1.json
|
||||||
def show
|
def show
|
||||||
@mapping = Mapping.find(params[:id])
|
@mapping = Mapping.find(params[:id])
|
||||||
authorize! @mapping
|
authorize @mapping
|
||||||
|
|
||||||
render json: @mapping
|
render json: @mapping
|
||||||
end
|
end
|
||||||
|
@ -17,8 +17,8 @@ class MappingsController < ApplicationController
|
||||||
# POST /mappings.json
|
# POST /mappings.json
|
||||||
def create
|
def create
|
||||||
@mapping = Mapping.new(mapping_params)
|
@mapping = Mapping.new(mapping_params)
|
||||||
authorize! @mapping
|
authorize @mapping
|
||||||
|
@mapping.user = current_user
|
||||||
if @mapping.save
|
if @mapping.save
|
||||||
render json: @mapping, status: :created
|
render json: @mapping, status: :created
|
||||||
else
|
else
|
||||||
|
@ -29,7 +29,7 @@ class MappingsController < ApplicationController
|
||||||
# PUT /mappings/1.json
|
# PUT /mappings/1.json
|
||||||
def update
|
def update
|
||||||
@mapping = Mapping.find(params[:id])
|
@mapping = Mapping.find(params[:id])
|
||||||
authorize! @mapping
|
authorize @mapping
|
||||||
|
|
||||||
if @mapping.update_attributes(mapping_params)
|
if @mapping.update_attributes(mapping_params)
|
||||||
head :no_content
|
head :no_content
|
||||||
|
@ -41,7 +41,7 @@ class MappingsController < ApplicationController
|
||||||
# DELETE /mappings/1.json
|
# DELETE /mappings/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@mapping = Mapping.find(params[:id])
|
@mapping = Mapping.find(params[:id])
|
||||||
authorize! @mapping
|
authorize @mapping
|
||||||
|
|
||||||
@mapping.destroy
|
@mapping.destroy
|
||||||
|
|
||||||
|
@ -51,6 +51,6 @@ class MappingsController < ApplicationController
|
||||||
private
|
private
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def mapping_params
|
def mapping_params
|
||||||
params.require(:mapping).permit(:id, :xloc, :yloc, :mappable_id, :mappable_type, :map_id, :user_id)
|
params.require(:mapping).permit(:id, :xloc, :yloc, :mappable_id, :mappable_type, :map_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue