2012-03-23 64 views
1

我正在关注Michael Hartl's book Ruby on Rails 3 Tutorail中的demo_app。该演示是一个简单的支架用户名:字符串email:字符串Javascript不适用于javascrip_inlcue-tag Rails 3.2.2

我得到一个错误,在我的application.html.erb文件:

Errno::EINVAL in Users#index 
Showing ~/demo_app/app/views/layouts/application.html.erb where line #6 raised: 
Invalid argument - cscript //E:jscript //Nologo //U /tmp/execjs20120323-4388-1an85xw-0.js 2>&1 
(in ~/demo_app/app/assets/javascripts/users.js.coffee) 

3: <head> 
4: <title>DemoApp</title> 
5: <%= stylesheet_link_tag "application", :media => "all" %> 
6: <%= javascript_include_tag "application" %> 
7: <%= csrf_meta_tags %> 
8: </head> 
9: <body> 

如果我chnage 6号线到:

<%= javascript_include_tag "default" %> 

该程序将运行完美,除非它不会允许我删除用户(大概是因为它没有运行javascript)。

环境信息:〜的

$ ruby -v 
ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-cygwin] 

$ rails -v 
Rails 3.2.2 

内容\ demo_app \程序\资产\ JavaScript的\ users.js.coffee:〜的

# Place all the behaviors and hooks related to the matching controller here. 
# All this logic will automatically be available in application.js. 
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ 

内容\ demo_app \程序\资产\ Java脚本\的application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files 
// listed below. 
// 
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 
// 
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 
// the compiled file. 
// 
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 
// GO AFTER THE REQUIRES BELOW. 
// 
//= require jquery 
//= require jquery_ujs 
//= require_tree . 
+0

发布您的'users.js.coffee'文件。 – James 2012-03-23 20:26:08

+0

你可以发布app/assets/javascripts/users.js.coffee的内容吗?同时确保您遵循本书Rails 3.2的版本 - http://ruby.railstutorial.org/ruby-on-rails-tutorial-book?version=3.2 – 2012-03-23 20:27:17

+0

john,确认我正在遵循version = 3.2。 – glennm 2012-03-23 20:51:14

回答

1

尝试取消注释宝石 'therubyracer'并运行捆绑,也最好使用最后一个稳定版本的红宝石

+0

我删除了关于therubyracer和bundle install的评论,运行时遇到了libv8 gem的问题。错误:“安装libv8时发生错误(3.3.10.4),并且Bundler无法继续。 请确保'gem install libv8 -v'3.3.10.4''在绑定之前成功。 – glennm 2012-03-24 18:35:30

+0

到解除停止libv8:混帐克隆[email protected]:fractaloop/libv8 CD libv8 --init 捆绑安装 束EXEC耙编译 – 2012-03-24 18:48:41

+0

说,即使我已经有了计划好的工作,混帐子模块更新我应该仍然按照你的建议取消注释gem therubyracer和卸载libv8? – glennm 2012-03-24 18:57:01

0

我搜索了周围其他问题,讨论了宝石therubyracer。我找到了一个答案,表明了Said Kaldybaev在此提出的建议。这对我没有用。但有另一个建议,从app/assets/javascripts/application.js文件中删除代码

//= require_tree . 

删除代码使应用程序工作(包括销毁功能)。

相关问题