RailsCasts Pro episodes are now free!
Learn more or hide this
<%= javascript_include_tag :defaults %>
<% form_remote_for :review, :url => reviews_path, :html => { :id => 'review_form' } do |f| %>
def create @review = Review.create!(params[:review]) flash[:notice] = "Thank you for reviewing this product" respond_to do |format| format.html { redirect_to product_path(@review.product_id) } format.js end end
page.insert_html :bottom, :reviews, :partial => 'review', :object => @review page.replace_html :reviews_count, pluralize(@review.product.reviews.size, 'Review') page[:review_form].reset page.replace_html :notice, flash[:notice] flash.discard