# Responding with JS respond_to do |format| if @review.save format.html { redirect_to @restaurant, notice: "yes" } # redirect_to @restaurant format.js # Returning JS as well else format.html { render action: new } format.js # Returning JS as well # render :new end # Responding with a custom JS file format.js { render :custom_create } # Responding with JS based on a condition format.js { render false ? :custom_create : :create } # Uses ternary operator