我的Rails 3.1.rc4应用程序工作正常,但我正在试图找出将js文件存储在管道中的适当方法.如果我将任何代码放在application.js以外的文件中,我会收到以下错误:
在2011-07-21 23:15:02 -0500开始GET"/assets/application.js"为127.0.0.1编译〜/ Dropbox/Rails/myapp/app/assets/javascripts/application.js.coffee(224ms) (pid 69397)编译资产application.js时出错:ExecJS :: ProgramError:SyntaxError:第1行的保留字"function"(在/Users/micahalcorn/Dropbox/Rails/myapp/app/assets/javascripts/users/registrations.js中.coffee)服务资产/application.js - 500内部服务器错误
发生这种情况而不管哪个文件(registrations在这种情况下)并要求该文件(在"保留字"不管第一字的var,function等).我使用node.js作为我的运行时环境,如果我删除coffeescript编译gems并将其视为Rails 3.0应用程序,一切正常.我想更好地理解资产管道并遵循惯例.谢谢你的任何建议!
node.js coffeescript ruby-on-rails-3.1 execjs asset-pipeline
我不喜欢在我不明白为什么有效的情况下.我觉得我正在使用垃圾袋和橡皮筋来固定漏水管道.自从升级到rails3.1以来,除非我将'execjs'和'therubyracer'添加到gemfile中,否则我无法使其工作.我不明白这些宝石甚至做了什么.我刚刚读了stackoverflow上的某个地方你必须添加它们才能使应用程序正常工作.谁知道这些宝石是为了什么?
我创建了一个新的Rails应用程序.当我尝试启动服务器时,出现以下错误:
[bathakarai@Project1-CO samp]$ rails server
/home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr in PATH, mode 040777
/home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.4/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /usr in PATH, mode 040777
/home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) …Run Code Online (Sandbox Code Playgroud) 更新:事情正在发挥作用!
感谢深度,我安装了node.js然后得到了一个TZInfo :: DataSourceNotFound错误,通过添加gem 'tzinfo-data', platforms: [:mingw, :mswin]和解决了bundle update.
谢谢你,先生 !
首先,我是一个完全初学者的轨道(只是为了让你得到我的初学者:我觉得自己只是在这里张贴的专家)这是我的第一个问题,所以请原谅我,如果我不是很明确.
所以,我是一个Windows 7用户,学习使用One Month课程的rails,我在尝试时遇到错误:
$ rake routes
rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://git
hub.com/sstephenson/execjs for a list of available runtimes.
c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7:in `<top (re
quired)>'
c:/Users/Marc Montagne/Desktop/pinteresting/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)
要么
$ rails server
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs/run
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi
thub.com/sstephenson/execjs for a list of …Run Code Online (Sandbox Code Playgroud) 我创建了一个数据库(空)的rails应用程序.当我尝试查看我的产品页面时,我在http:// localhost:3000/products页面上收到以下错误.在迁移数据库之前,应用程序确实起作用.我正在使用therubyracer,我在Windows 7上.
ExecJS::ProgramError in Products#index
Showing C:/RailsInstaller/DevKit/home/JP/nameofapp/app/views/layouts/application.html.erb where line #16 raised:
TypeError: Object doesn't support this property or method
(in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
Extracted source (around line #16):
13 <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
14
15 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
16 <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
17 <%= csrf_meta_tags %>
18
19 </head>
Rails.root: C:/RailsInstaller/DevKit/home/JP/nameofapp
Run Code Online (Sandbox Code Playgroud)
这是我在Rails服务器上得到的:
Started GET "/products" for 127.0.0.1 at 2015-04-23 22:28:06 -0400
ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM
"schema_migrations"
Processing by ProductsController#index …Run Code Online (Sandbox Code Playgroud) 在我的rails应用程序中,我使用highcharts来显示一些图表.而现在,我需要生成带图表的pdf(我将使用虾).我想知道我是否可以在pdf中使用highcharts.也许与ExecJS?或者替代虾?
谢谢!
我无法启动 Rails 服务器。显然我没有 JavaScript 运行时。
$ rails s
c:/Ruby22/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Run Code Online (Sandbox Code Playgroud)
我去了链接
但我不知道该怎么做。那么我究竟如何“安装”一个 JavaScript 运行时呢?
这里也是我的 GemFile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
# Use …Run Code Online (Sandbox Code Playgroud) 我正试图在debian上的rails上安装ruby ......我安装了一切.
我也安装了execjs,therubyracer和node.js.
每次我想创建一个新的控制器,它说:
/usr/local/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /usr/local/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs.rb:5:in `<module:ExecJS>'
from /usr/local/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `require'
from /usr/local/lib/ruby/gems/2.0.0/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /home/adattilo/test/testt/config/application.rb:7:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:44:in `require'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:44:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Run Code Online (Sandbox Code Playgroud)
安装execjs,therubyracer和node.js之后我重启了......
execjs ×8
javascript ×2
ruby ×2
coffeescript ×1
debian ×1
gem ×1
highcharts ×1
node.js ×1
pdf ×1
prawn ×1
therubyracer ×1
windows ×1
windows-10 ×1