Skip to content

Instantly share code, notes, and snippets.

@stuartbates
Created February 5, 2014 12:43
Show Gist options
  • Save stuartbates/8822825 to your computer and use it in GitHub Desktop.
Save stuartbates/8822825 to your computer and use it in GitHub Desktop.
Decorated version
def create
@wished_product = Spree::WishedProduct.new(params[:wished_product])
@wishlist = spree_current_user.wishlist
if @wishlist.include? params[:wished_product][:variant_id]
@wished_product = @wishlist.wished_products.detect {|wp| wp.variant_id == params[:wished_product][:variant_id].to_i }
else
@wished_product.wishlist = spree_current_user.wishlist
@wished_product.save
end
respond_with(@wished_product) do |format|
format.js { render action: "create" }
format.html { redirect_to wishlist_url(@wishlist) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment