I found out that my javascript code would not work when certain links where clicked.
When i set a breakpoint, the following js was not triggered after certain links
$(document).on('turbolinks:load', ready);
This is the link where js works
<%= link_to companies_path, method: :get, id: "Companies" do %>
This is the link where js does not work
<%= link_to "New Campaign", new_campaign_path, method: :get %>
The link with the attribute method: :get
would have a data-method="get"
in his html
<a id="Companies" data-method="get" href="/companies">
While the other one would not have this data-method.
<a class="btn btn-success btn-fill" data-method="get" href="/campaigns/new">New Campaign</a>
I solved the issue by explicitly declaring the data-method with the following syntax.
<%= link_to "New Campaign", new_campaign_path, method: :get %>
I did not find any discussion on StackOverflow explaining this, but please attach the links if you find them.
The issue is solved
Thanks Best Regards Fabrizio