-
-
Save denysonique/1489887 to your computer and use it in GitHub Desktop.
ujs problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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