link_to_remote on Rails 5

Asked

Viewed 50 times

0

I’m leaving for Rails 5 and I can’t find a replacement for the link_to_remote which has been discontinued.

In my old code, I have a "Register" link, which when clicked, makes a request to the "Register" action and renders the return in the div above "form".

Follow the basic elements of my view:

<%= javascript_include_tag :defaults %>

<div id="form">
</div>

<%= link_to_remote "Cadastro", :update => "form", 
      :url => { :action => "register" } %>

1 answer

0

In Rails 5, to perform an AJAX request, you must use the remote: true

The result according to your code looks something like this:

<%= link_to "Cadastro", action: "register", remote: true %>

According to Rails 5 documentation:

Documentação rails 5 sobre requisição ajax

If you want more information: link to the link_to helper documentation'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.