app/assets/javscripts/application.jsの修正
以下のコードの削除
application.js
//= require_tree .
共通のjavascript配置
common.jsの呼び出し
application.js
//= require common
コントローラ/アクション.js 形式でjavascriptの配置
app/assets/javascripts/top/index.js とか
app/assets/javascripts/top/create.js とか
views/layouts/application.html.erb の修正
<!DOCTYPE html>
<html>
<head>
<title>TestJs</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<%= javascript_include_tag "#{params[:controller]}/#{params[:action]}" if Rails.application.assets.find_asset("#{params[:controller]}/#{params[:action]}.js") %>
</head>
<body>
<%= yield %>
</body>
</html>
config/initializers/assets.rb の追加
Rails.application.config.assets.precompile += %w( top/index2.js )