From b1670b1595dc940b46be7c41452c10f2eef8e341 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 22 Jul 2011 16:17:13 -0400 Subject: [PATCH] fix bug with adding/removing wanted items --- app/controllers/closet_hangers_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/closet_hangers_controller.rb b/app/controllers/closet_hangers_controller.rb index a082025e..692d65d1 100644 --- a/app/controllers/closet_hangers_controller.rb +++ b/app/controllers/closet_hangers_controller.rb @@ -28,7 +28,12 @@ class ClosetHangersController < ApplicationController # expectations, though, and I can't really think of a genuinely RESTful way # to pull this off. def update - owned = (params[:closet_hanger][:owned] == 'true') if params[:closet_hanger] + if params[:closet_hanger] + owned = case params[:closet_hanger][:owned] + when 'true' then true + when 'false' then false + end + end owned ||= true @closet_hanger = current_user.closet_hangers.find_or_initialize_by_item_id_and_owned(@item.id, owned)