I got the View called Welcome. I created this manually. And since I don't need css/js files for this view, I do not want to create and put them onto the assets folder. But, I then I got this error:
Started GET "/javascripts/welcome.js" for ::1 at 2017-11-13 14:55:39 +0000
ActionController::RoutingError (No route matches [GET] "/javascripts/welcome.js"):
actionpack (5.0.0.rc2) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
And this error:
ActionController::RoutingError (No route matches [GET] "/stylesheets/welcome.css"):
Rendering /Users/ryzal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc2/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout
actionpack (5.0.0.rc2) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
I could make these errors go away by simply creating the welcome.js and welcome.css files and put them on the assets. BUT again, I do want to do this as I know I do not want and never want to use these files.
So how do I solve this?
FYI, my Rails app did not fail. It's all working fine. The errors that I got were appeared on my Terminal. See below:
And here is the only thing in my config/initializer/assets.rb
Rails.application.config.assets.version = '1.0'
In your layout:
<%= stylesheet_link_tag params[:controller] %>
<%= javascript_include_tag params[:controller] %>
This forces your application to load assets for any controller with current controller name (for welcome too). If you remove this, your error should disappear. Keep in mind, that this code can be useful for other controllers and you can lose some of your styles/javascripts. Include them all in application.js/.css files in your assets. No need to load assets separate in such dynamic way