Rails controller

PHOTO EMBED

Tue Jun 14 2022 10:50:39 GMT+0000 (Coordinated Universal Time)

Saved by @organic_darius

# 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
content_copyCOPY