gpt4 book ai didi

css - 在 Lynda.com Rails 教程中获取错误 "ExecJS::ProgramError in Subjects#index"

转载 作者:行者123 更新时间:2023-11-28 16:27:02 25 4
gpt4 key购买 nike

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

我正在阅读 Ruby on Rails 4 基本培训教程,并正在处理涵盖 Assets 的部分,我在其中导入了两个样式表(“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 样式表:

/*
* 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 View :

<% @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>

我的 gem 文件:

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]

如果信息太多/太少,我们深表歉意。任何帮助将不胜感激,谢谢!

最佳答案

好的!这为我修好了。此问题主要出现在 Windows 操作系统中。强制您的 Coffee Script Source 版本为 1.8.0。不正确支持更高版本。

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

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

然后更新 coffee-script-source 包

bundle update coffee-script-source

这应该可以解决问题。

关于css - 在 Lynda.com Rails 教程中获取错误 "ExecJS::ProgramError in Subjects#index",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35920551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com