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

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -