我正在编写 Michael Hartl Rails 教程(目前是第 7 章)。当我尝试运行服务器时出现此消息:
Sass::SyntaxError in Static_pages#home
Showing C:/rails_project/sample_app/app/views/layouts/application.html.erb where line #5 raised:
Invalid CSS after "}": expected "}", was ""
(in C:/rails_project/sample_app/app/assets/stylesheets/custom.css.scss)
Extracted source (around line #5):
2: <html>
3: <head>
4: <title><%= full_title(yield(:title)) %></title>
5: <%= stylesheet_link_tag "application", media: "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: <%= render 'layouts/shim' %>
Rails.root: C:/rails_project/sample_app
Application Trace | Framework Trace | Full Trace
app/assets/stylesheets/custom.css.scss:104
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___917874405_26658636'
来自 application.html.erb 的代码:
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>
</body>
</html>
不知道哪里出了问题。错误消息似乎不适合 aplication.html.erb 中存在的代码。有人知道吗?
最佳答案
错误在你的样式表中:
app/assets/stylesheets/custom.css.scss
您的应用程序使用的是 Sass (http://sass-lang.com),上面列出的文件存在问题。修复 .scss 错误,错误消息将消失。不幸的是,它似乎没有在该 .scss 文件中为您提供错误的行号。
关于css - Sass::静态页面中的语法错误#home Hartel 的教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12399254/