Errno::ENOENT No such file or directory Rails 4 - ruby-on-rails

Showing "/Users/Christian/Desktop/sample_app/app/views/layouts/application.html.erb" where line #5 raised:
No such file or directory - /Users/Christian/Desktop/vendor/assets
(in /Users/Christian/Desktop/sample_app/app/assets/stylesheets/custom.css.scss)
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>`
I was developing on linux ubuntu and it works fine there, I copied the folder to my mac and it no longer works. custom.css.scss is in the correct location
The problem is on line number 5 :
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>`

Change sass-rails version to 4.0.3 and leave the rest as it is. Remove Gemfile.lock when necessary, and then:
$ bundle update
$ bundle install
Finally, don't forget to restart your rails server!

In your Gemfile change the sass-rails version to 4.0.3. Get rid of a version number for sprockets. Delete the Gemfile.lock. Run the bundle install again

Related

Webpacker Deployment Issue Rails 6

Here is the error code:
ActionView::Template::Error (Webpacker can't find stylesheets in /app/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains: {
"application.css": "/packs/css/application-77c6d56c.css",
"application.js": "/packs/js/application-202b434086ff6248f760.js",
"application.js.map": "/packs/js/application-202b434086ff6248f760.js.map",
"entrypoints": {
"application": {
"css": [ "/packs/css/application-77c6d56c.css" ],
"js": [ "/packs/js/application-202b434086ff6248f760.js" ],
"js.map": [ "/packs/js/application-202b434086ff6248f760.js.map" ]
And the offending code is:
7: <%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" %>
8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
10: <%= stylesheet_pack_tag 'stylesheets', media: 'all', 'data-turbolinks-track': 'reload' %>
11: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
12: <link rel="stylesheet" href="https://unpkg.com/tailwindcss/dist/tailwind.min.css">
I realize that I have unnecessary link_tag(s), but I put them there just to make sure everything went through correctly. All of this works flawlessly in development but, once deployed to Heroku, it just crashes here so nothing is working right now.
I tried adding some #import(s) to connect all the css/js files to no avail. I'm not sure what the issue is at this point.
Using Rails 6, Webpacker, TailwindCSS, no real JS in usage so deleting all the script stuff wouldn't be a real issue, I just left it because this is a project still in development and will include JS at some point.
I had this same problem and noticed several templates/tutorials for adding Tailwind CSS to Rails specify adding to application.html.erb:
<%= stylesheet_pack_tag 'stylesheets', media: 'all', 'data-turbolinks-track': 'reload' %>
while others specify:
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
Not a webpack expert, but doing some reading convinced me that the name in the stylesheet_pack_tag helper is what webpack will look to bundle (from your \app\javascript\packs folder) but then is also the stylesheet name bundled by webpack (from your \public\packs\css folder) that your layout is looking for. It's really confusing, but I guess this is the convention over configuration thing. It also jives with the error being thrown above. If you rename your tag so it's application it should solve your error (at least it seemed to work for me). Maybe the stylesheets name is relevant for an older rails version?

JSON Parser Error Unexpected Token Error Rails

I recently cloned my Rails app, which was developed on Linux, to my Windows OS. There were a few errors, and I managed to fix most of them except this one. This error pops up when I try to access my page locally:
JSON::ParserError
419: unexpected token at ''
This is the code in question:
<head>
<title>DemoApp</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= javascript_include_tag "ckeditor/ckeditor.js" %>
<%= csrf_meta_tags %>
I researched and couldn't find a straightforward solution to this. I had previously changed my runtimes.rb to 'UTF-8' so that it will run in Windows.
Any help is much appreciated.
It could be because of a BOM or a tabulation space, it happens to me when I try to paste inside Vim.

Bootstrap Gem Installation Issue

I have added the bootstrap-sass gem and have installed the bundle. I have gone to github and think I have followed the directions correctly to finish the install for ruby on rails. It doesn't appear to be making a difference however on my local site - no font/formatting changes have been made, even after the install.
I am using a PC, https://github.com/findingtheway/pin
Change your app/views/layouts/application.html.erb to this:
<head>
<title>Pin</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
Rails uses application by default you have default which is why bootstrap is not loading.

Installing Bootstrap Gem

I'm currently learning ruby on rails and
trying to install bootstrap gem
but this message shows up when I do rails server.
An #import loop has been found:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
I followed every step correctly but this shows up

Ruby on Rails - Errno::EACCES in Posts#show

I'm doing this ruby on rails tutorial - http://guides.rubyonrails.org/getting_started.html
After doing 6.4 part, I started getting this error if I try to do anything. For I get this error when trying to see a post:
Errno::EACCES in Posts#show
Showing /home/user/rails/blog/app/views/layouts/application.html.erb where line #5 raised:
<html>
<head>
<title>Blog</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
Permission denied - /home/user/rails/blog/tmp/cache/assets/development/sass/bd7e1cc0cf5d133ac313bf5ffa5e5d87b843522a/comments.css.scssc
(in /home/user/rails/blog/app/assets/stylesheets/comments.css.scss)
Rails.root: /home/user/rails/blog
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__1904510075995834678_70186546148480'
Request
Parameters:
{"id"=>"1"}
It shows that this line raised an error:
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
And the file that shows I was denied to access (comments.css.scss), is empty, with just three comment lines. What could be wrong here? I followed tutorial guidelines, don't know what I could have done differently.
If your OS is Windows you can run this in the Windows command prompt.
icacls C:\User\username\rails\blog /grant Everyone:F
sudo chmod -R 777 /home/user/rails/blog will solve your problem.
give it a try...

Resources