I have recently been converted to the Ruby on Rails side so I am new to the art of the asset pipeline and ruby on rails in general. The problem that I am having at the moment is that when I try to load my ruby on rails page up it is getting a 404 error on my default.js
and my default.css
. These two files are in the directory app/assets/javascripts
and app/assests/stylesheets
respectively.
I believe that this problem is caused by my stylesheet_link_tags
and javascript_link_tags
inside my application.html.erb
. Below you can see my application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Loadtest</title>
<%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'default', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width = device-width, initial-scale = 1">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu">
</head>
<body>
<div id = "content">
<%= yield %>
</div>
</body>
</html>
At the beginning the link tags had application
after them but this SO Question led me to believe that changing them to default
would fix the problem.
The error that occurs when I change default
back to application
is the following
ExecJS::ProgramError in Application#home Showing c:/Users/***/Desktop/loadtest/app/views/layouts/application.html.erb where line #5 raised: TypeError: Object doesn't support this property or method Rails.root: c:/Users/aterra/Desktop/loadtest
I have not changed my application.js
or application.css
in any way and look how they would look when you build a rails application.
If you need to see my application controller it looks like this
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception def home end end
Any help in solving this question would be greatly appreciated. Thank you for you time.
EDIT:
I resolved my problem by changing default
to application.css
and application.js
respectively. After that I went into my application.js folder and added =require turbolinks
without the //
and then voila it started working.