Reputation: 127
I'm using a (messy) Bootstrap theme inside a Rails 4.2.2 app. When I type in localhost:3000, everything on my index.html.erb view loads perfectly. When I attempt to view that same index.html.erb view using a Back button (root_path) on another page, I get taken to localhost:3000 as I should, but only the navbar loads, and I get the below errors in the server logs. When I refresh that same page (localhost:3000), everything works fine.
I ran bundle exec rake assets:clean assets:precompile and restarted server, nothing changed.
What am I doing wrong? I don't understand why some JS files are working and I'm getting the error for these two particular JS files--or why everything loads properly on refresh.
Thanks.
PS edit: I'm deploying to Heroku but this fails in both dev and Heroku, so hopefully fixing in dev should be enough.
Server logs
ActionController::RoutingError (No route matches [GET] "/javascripts/modernizr-custom.js"):
.
.
.
ActionController::RoutingError (No route matches [GET] "/js/jquery.magnific-popup.js"):
index.html.erb:
<%= javascript_include_tag "modernizr-2.8.3.min" %>
<%= javascript_include_tag "articles" %>
<%= javascript_include_tag "bootstrap" %>
<%= javascript_include_tag "bootstrap.min" %>
<%= javascript_include_tag "classie" %>
<%= javascript_include_tag "comments" %>
<%= javascript_include_tag "html5shiv" %>
<%= javascript_include_tag "jquery-1.10.2" %>
<%= javascript_include_tag "jquery.corner" %>
<%= javascript_include_tag "jquery" %>
<%= javascript_include_tag "jquery.magnific-popup" %>
<%= javascript_include_tag "modernizr-2.8.3.min" %>
<%= javascript_include_tag "modernizr-custom" %>
<%= javascript_include_tag "owl.carousel" %>
<%= javascript_include_tag "PIE_IE678" %>
<%= javascript_include_tag "script" %>
<%= javascript_include_tag "stickUp.min" %>
<%= javascript_include_tag "uiMorphingButton_inflow" %>
<%= javascript_include_tag "welcome" %>
<%= javascript_include_tag "wow.min" %>
assets.rb:
#Javascripts
Rails.application.config.assets.precompile += %w( application.js )
Rails.application.config.assets.precompile += %w( articles.coffee )
Rails.application.config.assets.precompile += %w( bootstrap.js )
Rails.application.config.assets.precompile += %w( bootstrap.min.js )
Rails.application.config.assets.precompile += %w( classie.js )
Rails.application.config.assets.precompile += %w( comments.coffee )
Rails.application.config.assets.precompile += %w( html5shiv.js )
Rails.application.config.assets.precompile += %w( jquery-1.10.2.js )
Rails.application.config.assets.precompile += %w( jquery-1.9.1.min.js )
Rails.application.config.assets.precompile += %w( jquery.corner.js )
Rails.application.config.assets.precompile += %w( jquery.js )
Rails.application.config.assets.precompile += %w( jquery.magnific-popup.js )
Rails.application.config.assets.precompile += %w( modernizr-2.8.3.min.js )
Rails.application.config.assets.precompile += %w( modernizr-custom.js )
Rails.application.config.assets.precompile += %w( owl.carousel.js )
Rails.application.config.assets.precompile += %w( PIE_IE678.js )
Rails.application.config.assets.precompile += %w( PIE_IE9.js )
Rails.application.config.assets.precompile += %w( script.js )
Rails.application.config.assets.precompile += %w( stickUp.min.js )
Rails.application.config.assets.precompile += %w( uiMorphingButton_inflow.js )
Rails.application.config.assets.precompile += %w( welcome.coffee )
Rails.application.config.assets.precompile += %w( wow.min.js )
application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require bootstrap
//= require_tree .
Both jquery.magnific-popup.js and modernizr-custom.js are in my javascripts folder.
Upvotes: 0
Views: 522
Reputation: 141
It sounds like the issue might be turbolinks. It can affect the state of your page like that. If you don't think that your app can benefit from the use of AJAX to speed up page rendering, you might as well remove it.
Upvotes: 1