`
gazeldx
  • 浏览: 102533 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Ruby On Rails异常和解决汇总

阅读更多

/usr/lib/ruby/gems/1.8/gems/execjs-1.2.7/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /usr/lib/ruby/gems/1.8/gems/execjs-1.2.7/lib/execjs.rb:5
    from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
   ...
    from script/rails:6:in `require'
    from script/rails:6
解:在gemfile中加gem 'therubyracer',后bundle install

 

 

$ rake db:migrate报错:

rake aborted!

You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Consider using bundle exec.

$ gem list发现
rake (0.9.2.2, 0.9.2)
因此$ gem uninstall rake -v 0.9.2.2
 
 
有一次,我bundle install老是过不去。报错:
/home/zj/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:122:in `initialize': no metadata found in /home/zj/.rvm/gems/ruby-1.9.2-p290@rails3.1.3/cache/json-1.6.5.gem (Gem::Package::FormatError)
from /home/zj/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:20:in `new'
上网搜了一会,没有合适的结果。后来我就找到这个json-1.6.5.gem,发现旁边还有一个json-1.6.4.gem,而这个json-1.6.5.gem大小是286k,json-1.6.4.gem是415k,所以我觉得不太对劲,索性把它删了。再来bundle install,OK,它给我下载了一个完整的了,现在OK了。

 

在production模式下,发现所有assets下面的css和js都无法访问了,原因是config.serve_static_assets = true这一句写成了false。

 

今天发现我在服务上的所有针对production的操作全部编成了针对development mode的操作了,原来我需要写成:

RAILS_ENV=production rails console

或者

RAILS_ENV=production rails runner ...

这是关键,不能用-e production。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics