Javascript不适用于javascrip_inlcue-tag Rails 3.2.2

时间:2012-03-23 20:19:49

标签: javascript ruby-on-rails ruby-on-rails-3

我正在关注Michael Hartl's book Ruby on Rails 3 Tutorail中的demo_app。该演示是一个简单的Scaffold用户名:string email:string

我的 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>

如果我将第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 \ app \ assets \ javascripts \ 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 \ app \ assets \ javascripts \ 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 .

2 个答案:

答案 0 :(得分:1)

尝试取消注释 gem'therubyracer'并运行捆绑,并且最好使用ruby的最后稳定版本

答案 1 :(得分:0)

我在周围寻找讨论宝石温控器的其他问题。我找到了一个答案,表明了卡尔迪巴耶夫在这里所说的话。这对我不起作用。但是还有另一个建议要删除代码

//= require_tree . 
来自app / assets / javascripts / application.js文件的

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