Skip to content

Instantly share code, notes, and snippets.

@phlipper
Created December 10, 2009 19:32
Show Gist options
  • Save phlipper/253589 to your computer and use it in GitHub Desktop.
Save phlipper/253589 to your computer and use it in GitHub Desktop.
<!-- _product.html.erb -->
<% div_for(product) do %>
<p id="<%= dom_id(product, "price") %>"><%=h product.price %></p>
<!-- periodic update ... -->
<%= image_tag(product.photo.url(:thumb), :id => dom_id(product, "photo")) %>
<% end %>
<!-- index.html.erb -->
<%= render @products %>
def update
@product = Product.find(params[:id])
@product.update_attributes(params[:product])
respond_to do |wants|
wants.html { redirect_to products_url }
wants.js do
render :update do |page|
# something like this ...
page[dom_id(@product)].replace :partial => @product
# OR maybe something like this ...
page[dom_id(@product, "price")].replace_html @product.price
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment