更改application.js时如何避免在Rails> = 3.1资产管道中进行预编译 [英] How to avoid precompiling in Rails >= 3.1 asset pipeline when changing application.js

查看:57
本文介绍了更改application.js时如何避免在Rails> = 3.1资产管道中进行预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在升级到Rails 3.1(后来又升级到3.2)之后,我在资产管道中预编译了文件 现在(在开发模式下工作)我必须在每次更改后重新编译它们才能看到它们的出现.由于大约需要一分钟,因此开发几乎是不可能的.

I precompiled my files in the asset pipeline after upgrading to rails 3.1 (and later to 3.2) Now (working in development mode) I have to recompile them after every change to see them appear. As this takes about one minute, development is nearly impossible.

我在config/development.rb

config.cache_classes = false

# Show full error reports and disable caching
config.consider_all_requests_local       = true
config.action_controller.perform_caching = false

# Do not compress assets
config.assets.compress = false

config.assets.compile = true

# Expands the lines which load the assets
config.assets.debug = true

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.3

# configuration option config.assets.logger to control Sprockets logging
config.assets.logger = nil

怎么了?我怎么能突然看到我在application.js和其他地方所做的更改?

What is wrong? How can I see the changes i make in application.js and others suddenly?

推荐答案

一个必须手动执行

 $ bundle exec rake assets:clean

这将删除[app]/public/assets/中的所有文件. (警告那里的其他文件属于模型(例如用户照片),它们也会被删除!).

Which will remove all files in [app]/public/assets/. (Caution with otherfiles there, belonging to a model (like users pics), they also get removed!).

当文件不存在时,将使用原始文件.因此,对于开发模式而言,预编译资产似乎不是必需的.

When the files do not exist the original ones are used. So precompiling assets seems not necessary for development mode.

感谢 @shingara 对问题的提示.

这篇关于更改application.js时如何避免在Rails> = 3.1资产管道中进行预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆