How to avoid precompiling in Rails >= 3.1 asset pipeline when changing application.js

一个人想着一个人 提交于 2019-12-14 03:42:48

问题


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.

I have made the following relevant entries in 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

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


回答1:


One has to manually do

 $ bundle exec rake assets:clean

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.

Thanks @shingara for the hint in his comment to the question.




回答2:


Something which might be a factor is if the following directive is in config/application.rb:

config.assets.precompile  += [ 'asset-file', ... ]

This should either be limited to 'fixed' asset files, or moved to config/environments/production.rb.

Not sure if that is happening with your situation, however it would produce similar results of not seeing changes after editing the asset file. Not precompiling assets will save you from needing to compile them each iteration in development.



来源:https://stackoverflow.com/questions/9733999/how-to-avoid-precompiling-in-rails-3-1-asset-pipeline-when-changing-applicati

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!