ruby on rails - How to redirect/ render to another controller's view? -
once pet saved, want redirect treats/show controller. tried doing takes me pets/show.
def create @pets = pet.new(pet_params) respond_to |format| if @pet.save format.html { redirect_to @treat} format.json { template: treats/show, status: :created, location: @pet } else format.html { render :new } format.json { render json: @pet.errors, status: :unprocessable_entity } end end end
you redirect path:
format.html { redirect_to(treat_path(@treat) }
Comments
Post a Comment