Errno::ENOENT in home#index with ExecJS - ruby-on-rails

I just created a sample Rails project running in Windows and ran rails s, which ran fine for setup. Later, I created a resource called resources :crm and generated the necessary components. I ran into this error that is quite bugging me much. I tried degrading ExecJS but no avail. I also installed Node.js, but that didn't work either. Here is the error log:
Showing C:/Users/Rodrigo Argumedo/projects/CRM/app/views/layouts/application.html.erb where line #6 raised:
No such file or directory # unlink_internal - C:/Users/Rodrigo Argumedo/AppData/Local/Temp/execjs20150622-2296-sj99kvjson
Rails.root: C:/Users/Rodrigo Argumedo/projects/CRM
Is there a solution to this? If so, guide me where to fix this particular error?
EDIT:
Application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Sample Rails</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

It turns out it was a ExecJS problem and forced to run bundle install -f to reinstall the gems and it worked again.

Related

Getting the error NoMethodError in Users#index when using Rails 5.0.6, Oracle 12c Ruby 2.5 on Ubuntu 16.04

I have a very small test App using only one table, Users having couple columns. The purpose is to find a way to migrate a Ruby on Rails App from using PostgreSQL to using Oracle.
The exactly same App works perfect if I am using PostgreSQL.
When switching to Oracle, I am getting this error (for the code in the file application.html.erb):
NoMethodError in Users#index Showing
/home/levi/ror/testora/app/views/layouts/application.html.erb where
line #7 raised: undefined method `success?' for nil:NilClass Extracted
source (around line #7):
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
The error occurs when the URL for Users Index is used
http://localhost:3000/users
Instead of the error, I am expecting to see something like this:
Users
Name Dob Gender
Levi 1963-07-31 M Show Edit Destroy
Adina 1966-09-02 F Show Edit Destroy
New User
If I am commenting these 2 lines
<%#= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%#= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
I am getting a basic page rendered as mention above.
Here is my application.html.erb file.
<!DOCTYPE html>
<html>
<head>
<title>Testora</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
The Gemfile contains these lines:
# Use oracle as the database for Active Record
gem 'ruby-oci8', '~>2.2'
# Use oracle as the database for Active Record
gem 'activerecord-oracle_enhanced-adapter', '1.7.0'
And I am able to test / work with the Users controller and model when using rails db and rails console.
I am suspecting that this is related to assets pipeline and turbo-links.
I don't know what the error may be and how to fix it?

Get 'Zone already loaded' error in Rails + webpack + angular 2 initial setup

I used following specifications.
1) rails 5.1.3
2) ruby 2.4.1
3) rail with webpacker
4) Angular 4.3.4 with webpacker (Typescript)
I create new rail app using command rails new my-rails-app --webpack-angular.
Folder structure
After that, as per instruction under app/javascript/packs/application.js and app/javascript/packs/hello_angular.js, I added <%= javascript_pack_tag 'application' %> in application.html.erb to head tag next after javascript_include_tag.
Also add below markup to body tag in layout application.html.erb
// <hello-angular>Loading...</hello-angular>
//
// <%= javascript_pack_tag 'hello_angular' %>
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>AngularOnRailsWithWebpack</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application' %>
</head>
<body>
<hello-angular>Loading...</hello-angular>
<%= javascript_pack_tag 'hello_angular' %>
<%= yield %>
</body>
</html>
Now create new scaffolding by running rails g scafolld post title:string desc:text and set post index page as root path
Now run rails server by running rails s and webpack server by running ./bin/webpack-dev-server
Works fine.
But When I navigate routes by click on new post or edit post it fire errors in web console like below.
Solution I tried
1) Remove javascript_include_tag from application.html.erb. But it will remove turbolink. I don't want to remove that.
2) Restore javascript_include_tag and update index.ts under app/javascript/hello-angular/index.ts. Add turbolink load event as per this video instruction https://www.youtube.com/watch?v=lGToT9RyDxc
Index.ts
import './polyfills.ts';
import { platformBrowserDynamic } from '#angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
document.addEventListener('turbolinks:load', () => {
platformBrowserDynamic().bootstrapModule(AppModule);
})
Work fine. It will render code fine but still same zone error in web console.
May be this is rails issue. If so then I hope it will resolve in next patch release.
Can any one help that how to resolve this issue ? What I am doing wrong.

Cannot load javascript module in rails 5.1

I am trying to load a simple vue module in my layout application file
but the app is failing to load the module. I am using the webpacker gem with rails 5.1.1. and ruby version 2.3.3
Here is my code
<!DOCTYPE html>
<html>
<head>
<title>Potato</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'hello_vue' %>
<%= stylesheet_pack_tag 'hello_vue' %>
</head>
<body>
<%= yield %>
</body>
</html>
The hello_vue.js file (see code below) is located in the javascript/packs directory and it's importing a very basic hello.vue file also located the same directory:
import Vue from 'vue'
import App from './app.vue'
document.addEventListener('DOMContentLoaded', () => {
document.body.appendChild(document.createElement('hello'))
const app = new Vue(App).$mount('hello')
console.log(app)
})
I've tried to restart the rails server and the webpack-dev-server but nothing...
the app seems just to ignore the file.
I've generated a controller Pages with an index action and now it's working...

Sass::SyntaxError: File to import not found or unreadable

I am using Rails 5 on my project and i am new on Rails. When i running
rake assets:precompile
I got error
Sass::SyntaxError: File to import not found or unreadable: mycustomize.
mycustomize.scss is my customize css file which is in /app/assets/stylesheets folder.
I searched a solution is change application.css to application.scss it do works, but i got a new error:
ActionController::RoutingError (No route matches [GET] “/stylesheets/application.css”)
Anyone can explain and help on this. Thank you!
EDIT
application.html.erb
<head>
<title>GoalStack</title>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
EDIT2
Before i add mycustomize.scss i use application.css which works well on server. I am trying to add some customize layout so i created mycustomize.scss and in application.css i add
#import "mycustomize";
After all of this all works well locally. When i try to deploy to my staging server, i got the error described above.
config.public_file_server.enabled = false
did the trick, thanks Arup Rakshit.

Michael Hrtl's Ruby on Rails Tutorial ep 5. Changing the hash from :media to media: doesn't work

only on tutorial 5 and I am stumped.
This is similar to a previous post by user1420228, but the answer given didn't really resolve the problem.
In Michael Hartl's application_helper.rb file:
<!DOCTYPE html>
<html>
<head>
<title> <%=full_title(yield(:title)) %> </title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
However, he suggests changing the :media hash to the newer media:.
He makes the change and demonstrates the sample app working.
I made the same change and the sample app failed with the following error:
SyntaxError in Static_pages#home
Showing /Users/osmanahmed/Rails_Projects/sample_app/app/views/layouts/application.html.erb where line #5 raised:
/Users/osmanahmed/Rails_Projects/sample_app/app/views/layouts/application.html.erb:5: syntax error, unexpected tASSOC
...tag "application", media: => "all" );#output_buffer.safe_...
... ^
Extracted source (around line #5):
2: <html>
3: <head>
4: <title> <%=full_title(yield(:title)) %> </title>
5: <%= stylesheet_link_tag "application", media: => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
Trace of template inclusion: app/views/layouts/application.html.erb
Rails.root: /Users/osmanahmed/Rails_Projects/sample_app
ruby -v gives me: ruby 1.9.3p392
rvm -v gives me 1.20.13
rails - v is 3.2.13
As a side issue, if I ignore the change to the new hash everything works fine, but if I progress further in the tutorial I find that my static home page contents load twice. So I suspect I should try and fix this issue before I try and debug the new "page loading twice error"
I am guessing this is a configuration issue, either I have loaded the incorrect gemfile or something.
Can anyone point me in the right direction please?
Oz
Looks like you're doing media: => "all". It should be media: "all". No hash-rocket.

Resources