开发者

Rails 3.1 asset pipeline: Ignore backup files from Emacs and other editors

In a Rails 3.1 project, if I edit app/assets/javascripts/users.js.coffee using Emacs, then Em开发者_Go百科acs creates a backup file named app/assets/javascripts/users.js.coffee~ (note the trailing "~").

Unfortunately, the new Rails 3.1 asset pipeline sees this .coffee~ file, and injects it directly into the generated application.js, which in turn causes JavaScript errors in the browser.

I could turn off backups in Emacs by writing:

(setq backup-directory-alist nil)

...or I could use:

(setq backup-directory-alist `(("." . "~/.emacs-backups")))

...to move them into another directory.

But this would require every Emacs user on the project to reconfigure their Emacs, which is undesirable. I would prefer to configure Rails 3.1 to ignore files ending in .coffee~. Is there an easy way to do this?


I thought this was a defect in the require_tree method; and it sort of is, seems to be a few issues filed on this:

https://github.com/rails/rails/issues/1863#issuecomment-1543809 (Rails) https://github.com/sstephenson/sprockets/pull/119 (Sprockets) https://github.com/sstephenson/hike/issues/9 (Hike, fix was made here)

looks like it was fixed recently, after Rails rc4 (hike-1.1.0), looks like hike-1.2.0 has been released with the fix, you could try updating your Gemfile to use the newer version

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜