在Lynda.com Rails教程中获取错误“ExecJS :: ProgramError in Subjects #index”

时间:2016-03-10 15:22:55

标签: css ruby ruby-on-rails-4

首先我要说的是,如果我没有尽可能清楚地解释我的问题,我很抱歉,我是Ruby on Rails的新手,这是我第一次在这里问一个问题而不是立即在这里找到答案。

我正在阅读Ruby on Rails 4基本培训教程,并正在研究我导入两个样式表(“admin.css”和“public.css”)的资产部分,然后更改了应用程序中的代码.css样式表包含这两个文件。

然后我创建了一个名为admin.html.erb的新布局,并插入以下行来引用新的样式表:

<%= stylesheet_link_tag('application', :media => 'all') %>

但是现在我在我的应用中加载任何页面时都会出现以下错误:

Here's the error I keep getting in my rails app.

我在这里看到了几个类似的问题,但他们的所有代码都在我的下面另一行引用了需要修复的JavaScript。通常第二行改为:

<%= stylesheet_link_tag('default', :media => 'all') %>

但这只是为了没有样式表加载。

以下是我的文件: admin.html.erb布局

<!DOCTYPE html>
<html>
<head>
    <title>Simple CMS | <%= @page_title || "Admin" %></title>
    <%= stylesheet_link_tag('application', :media => 'all') %>
</head>
<body>
    <div id="header">
        <h1>Simple CMS Admin</h1>
    </div>
    <div id="main">
        <% if !flash[:notice].blank? %>
            <div class="notice">
                <%= flash[:notice] %>
            </div>
        <% end %>
        <div id="content">
            <%= yield %>
        </div>
    </div>
    <div id="footer">
        <p id="copywright">&copy; lynda.com / Brian Arpaio</p>
    </div>
</body>
</html>

application.css stylesheet:

/*
* This is a manifest file that'll be compiled into application.css, which      will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets,  vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require public
*= require admin
*= require_self
*/

我的主题index.html.erb查看:

<% @page_title = "Subjects" %>
<div class="subjects index">
  <h2>Subjects</h2>

<%= link_to("Add new subject", {:action => 'new'}, :class => 'action new') %>

<table class="listing" summary="Subject list">
    <tr class="header">
        <th>&nbsp;</th>
        <th>Subject</th>
        <th>Visible</th>
        <th>Pages</th>
        <th>Actions</th>
    </tr>
    <% @subjects.each do |subject| %>
    <tr>
        <td><%= subject.position %></td>
        <td><%= subject.name %></td>
        <td class="center"><%= status_tag(subject.visible) %></td>
        <td class="center"><%= subject.pages.size %></td>
        <td class="actions">
            <%= link_to("Show", {:action => 'show', :id => subject.id}, :class => 'action show') %>
            <%= link_to("Edit", {:action => 'edit', :id => subject.id}, :class => 'action edit') %>
            <%= link_to("Delete", {:action => 'delete', :id => subject.id}, :class => 'action delete') %>
        </td>
    </tr>
    <% end %>
</table>

我的宝石文件:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.13', '< 0.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read    more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end

group :development do
 # Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

很抱歉,如果这太多/太少信息。非常感谢任何帮助,谢谢!

1 个答案:

答案 0 :(得分:1)

好!这为我修好了。此问题主要发生在Windows操作系统中。强制您的咖啡脚本源版本为1.8.0。不支持更高版本。

更改或添加到您的gem文件:

gem 'coffee-script-source', '1.8.0'

然后更新coffee-script-source bundle

bundle update coffee-script-source

这应解决问题。