gpt4 book ai didi

ruby-on-rails - Rails 3.1.0 ActionView::Template::Error (application.css 未预编译)

转载 作者:行者123 更新时间:2023-12-03 04:02:06 25 4
gpt4 key购买 nike

我使用带有索引功能的简单页面 Controller 制作了一个基本的 Rails 应用程序,当我加载页面时,我得到:

ActionView::Template::Error (application.css isn't precompiled):
2: <html>
3: <head>
4: <title>Demo</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__43625033_88530400'

gem 文件

source 'http://rubygems.org'

gem 'rails', '3.1.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

gem 'execjs'
gem 'therubyracer'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end

gem 'jquery-rails'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
# Pretty printed test output
gem 'turn', :require => false
end

最佳答案

默认情况下,Rails 假定您已在生产环境中预编译了文件,如果您想在生产环境中使用实时编译(在运行时编译您的资源),则必须将 config.assets.compile 设置为 true.

# config/environments/production.rb
...
config.assets.compile = true
...

当您使用预编译资源但缺少任何预编译文件时,您可以使用此选项回退到 Sprockets。

如果 config.assets.compile 选项设置为 false 并且缺少预编译文件,您将收到“AssetNoPrecompiledError”,指示缺少文件的名称。

关于ruby-on-rails - Rails 3.1.0 ActionView::Template::Error (application.css 未预编译),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7275636/

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