def admin_update
      return unless user_is_allowed('categories', 'edit')
      
      # Define category and initialize response
      category = Category.find(params[:id])
      response = { attributes: Hash.new }
      
      # Iterate over params and update relevant attributes
      params.each do |key, value|
        case key
        when 'name' then category.name = value
        when 'slug' then category.slug = value
        when 'status' then category.status = value
        when 'image' then category.image = value
        end
      end
      
      # Try and save category
      response[:success] = category.save
      
      # If an image is passed, return the url
      response[:attributes][:image] = { value: category.image.url(:medium) } if params[:image]
      
      # Respond to update request
      render :json => response
    end
def admin_update
      return unless user_is_allowed('categories', 'edit')
      
      # Define category and initialize response
      category = Category.find(params[:id])
      response = { attributes: Hash.new }
      
      # Iterate over params and update relevant attributes
      params.each do |key, value|
        case key
        when 'name' then category.name = value
        when 'slug' then category.slug = value
        when 'status' then category.status = value
        when 'image' then category.image = value
        end
      end
      
      # Try and save category
      response[:success] = category.save
      
      # If an image is passed, return the url
      response[:attributes][:image] = { value: category.image.url(:medium) } if params[:image]
      
      # Respond to update request
      render :json => response
    end
PUT /admin/categories/:id