From 90f24775661b812de86e8c827734151290b14d93 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Thu, 11 Sep 2014 08:35:16 -0400 Subject: [PATCH] fixed map update controller --- app/controllers/maps_controller.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 28af22b2..72d81656 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -193,15 +193,14 @@ class MapsController < ApplicationController @current = current_user @map = Map.find(params[:id]).authorize_to_edit(@current) - if @map - @map.name = params[:name] if params[:name] - @map.desc = params[:desc] if params[:desc] - @map.permission = params[:permission] if params[:permission] - @map.save - end - respond_to do |format| - format.json { render :json => @map } + if !@map + format.json { render json: "unauthorized" } + elsif @map.update_attributes(params[:map]) + format.json { head :no_content } + else + format.json { render json: @map.errors, status: :unprocessable_entity } + end end end