I have problems to add remote links to an isolated rails plugin. When I click on the link, it does nothing. I don't even get any error messages, it just does nothing.
This is the link:
<!-- app/views/my_plugin/models/new.html.erb -->
...
<fieldset id="attrs">
<legend><%= t 'my_plugin.attrs' %></legend>
<%= link_to t('my_plugin.new_attr'), models_add_attr_url, :remote => true %>
</fieldset>
...
This is my route:
# config/routes.rb
MyPlugin::Engine.routes.draw do
...
get 'models/add_attr'
end
This is my controller:
# app/controllers/my_plugin/models_controller.rb
require_dependency "my_plugin/application_controller"
module MyPlugin
class ModelsController < ApplicationController
...
# GET /models/add_attr
def add_attr
respond_to { |format| format.js }
end
...
end
end
This is my js file, just a test:
// app/views/my_plugin/models/add_attr.js.erb
console.log('hello');
This is my engine:
# lib/my_plugin/engine.rb
module MyPlugin
class Engine < ::Rails::Engine
require 'jquery-rails'
require 'turbolinks'
isolate_namespace MyPlugin
end
end
This is my gemspec:
# my_plugin.gemspec
...
Gem::Specification.new do |spec|
...
spec.add_dependency "rails", "~> 5.2"
spec.add_dependency 'jquery-rails', '~> 4.3'
spec.add_dependency 'turbolinks', '~> 5.2'
...
end
I hope I have provided enough info. Thanks for any help.