我通过在我的 Rakefile 中添加一些 voodoo 来禁用 assets:precompile rake 任务来解决这个问题。
首先我添加 user-env-compile labs 组件
heroku labs:enable user-env-compile
然后将此添加到我的 Rakefile 的开头
# found from http://blog.jayfields.com/2008/02/rake-task-overwriting.html
# used by conditional heroku asset compile magick
class Rake::Task
def overwrite(&block)
@actions.clear
enhance(&block)
end
end
然后我在 lib/tasks/disable_assets_on_heroku.rake 中添加这个 rake 任务
if ENV['RAILS_ENV'] == 'development'
namespace :assets do
task(:precompile).overwrite do
puts "Asset precompile skipped in #{ENV['RAILS_ENV']}"
end
end
end