Skip to content

Instantly share code, notes, and snippets.

@denysonique
Forked from mauriciofierrom/gist:1489885
Created December 17, 2011 10:26
Show Gist options
  • Save denysonique/1489887 to your computer and use it in GitHub Desktop.
Save denysonique/1489887 to your computer and use it in GitHub Desktop.
ujs problem
def create
@cart = current_cart
product = Product.find(params[:product_id])
@line_item = @cart.add_product(product.id)
respond_to do |format|
if @line_item.save
format.html { redirect_to(store_url)}
format.js { @current_item = @line_item }
format.xml { render :xml => @line_item, :status => :created, :location => @line_item }
else
format.html { render :action => "new" }
format.xml { render :xml => @line_item.errors, :status => :unprocessable_entity }
end
end
end
the ujs template has only this line:
alert("hey there, the cart id is <%= escape_javascript(@current_item.quantity) %>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment