Ajax in ruby on rails, the remote process does not work: true

0

I have a form on the home page (all created with scaffold), which I would like when I click on the publish button, I will add the publication to the same home via ajax.

add remote true to the form

= form_for @post, remote: true do |f| 

effectively in the navigator element inspector, the form appears in the form:

data-remote="true"

The thing is that even though he sent the request in js he always redirects me to http://localhost:3000/posts/28

instead of staying on the same page waiting for the response file to be able to add it to the home page

I'm using rails 5.0.3 Does anyone know if for that version of rails (remote: true does not work anymore) or do you have to take another step to stop the response in html?

    
asked by Jeff Ruby 07.06.2017 в 20:50
source

1 answer

1

I must thank Martouta who made a fork about it.

it happened that in app / controllers / posts_controller.rb a line specifying format.js { render :show } was missing so that the answer in js was accepted.

    
answered by 08.06.2017 в 00:07