Rails 3.1:无法在应用程序中启用资产管道

发布于 2024-12-12 00:00:12 字数 634 浏览 0 评论 0原文

我有 3.1 应用程序。 一开始我添加了 config.assets.enabled = false 不使用管道。

现在我已经评论了这一行。重新启动服务器。

app\assets\javascripts\application.js

我在我的布局视图中使用了 : <%= javascript_include_tag "application" %>

我的页面尝试加载 "javascripts/application.js" 而不是 asset/application.js

我的配置可能有问题?

gemfile(不必要的删除):

gem 'rails', '3.1.1'

gem 'sqlite3'

# Asset template engines
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

I've got 3.1 application.
At the beginning i'd added
config.assets.enabled = false
not to use pipeline.

Now i've commented this line. restart server.

I've got app\assets\javascripts\application.js

In my layout view I use:
<%= javascript_include_tag "application" %>

my page tries to load "javascripts/application.js" not assets/application.js

What may be wrong in my configuration?

gemfile (unnecessary removed):

gem 'rails', '3.1.1'

gem 'sqlite3'

# Asset template engines
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山人契 2024-12-19 00:00:12

您是否尝试过将其保留并使其 config.assets.enabled = true 而不是注释掉该行?看起来默认值总是false,因此您需要显式地将其设置为true

Rather than commenting out the line, have you tried leaving it in and making it config.assets.enabled = true instead? It looks like the default value will always be false, so you need to explicitly set it to true.

半窗疏影 2024-12-19 00:00:12

如果关闭管道,Rails 帮助程序将恢复到 javascript 和 CSS 的旧路径 - 在 /public 目录中的这些文件夹中。如果您不想使用管道,那么您必须使用这些文件夹,而不是资产文件夹。

Dylan 是正确的 - 您必须显式启用管道,这是新生成的应用程序的默认设置。

If you turn the pipeline off then the Rails helpers revert to the old paths to javascript and CSS - in those folders in the /public directory. If you don't want to use the pipeline then you have to use those folders instead, not the assets folder ones.

Dylan is correct - you have to explicitly enable the pipeline, and this is the default for a new generated app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文