即使重新启动服务器,Rails开发环境也不会更新html / css / assets [英] Rails dev environment not updating html/css/assets even after restarting server

查看:84
本文介绍了即使重新启动服务器,Rails开发环境也不会更新html / css / assets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个铁路站点,一切进展都比较顺利。突然我对视图和资产的更改不再显示。我更改了样式表或某些html,并在 http://0.0.0.0:3000 处重新加载了浏览器,但没有任何变化。因此,我重新启动WEBrick,仍然没有任何改变。

I've been developing a site in rails, everything going relatively smooth. Suddenly my changes to the views and assets no longer show up. I change a stylesheet or some html and reload my browser at http://0.0.0.0:3000 and nothing changes. So I restart WEBrick and still nothing's changed. This is even the case if I change an image entirely.

获得新更改的唯一方法是预编译资产:

The only way to get the new changes is to precompile the assets:

C:\Users\me\website>rake assets:precompile
C:/Ruby193/bin/ruby.exe C:/Ruby193/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

为什么将生产显示为RAILS_ENV?也许我的开发环境以某种方式变成了生产环境?但是即使那样,我也不需要预先编译资产以反映​​更改。无论如何, Rails.env.development吗?返回 true Rails.env.production?在控制器和erb文件中返回 false

Why is it showing production as the RAILS_ENV? Maybe my development environment somehow turned into the production environment? But even then I shouldn't need to precompile assets to get changes reflected. Anyway Rails.env.development? returns true and Rails.env.production? returns false in controllers and erb files.

我尝试删除/ tmp目录

I've tried deleting my /tmp directory to no avail.

为了使Heroku使用指南针,我必须在config / application.rb中添加以下行:

I had to add the following line to config/application.rb in order to get Heroku to work with compass:

config.assets.initialize_on_precompile = false

但是,删除该行对我的问题无济于事。

However, removing that line didn't help my issue anyway.

推荐答案

删除 public / assets / 目录。那就是预编译文件所在的位置,如果存在,则将它们提供,而不是将请求传递到Sprockets。您可以放心地对整个目录进行核对,然后事情应该会再次起作用。

Delete the contents of your public/assets/ directory. That's where precompiled files go, and they're served if they exist, rather than the request falling through to Sprockets. You can safely just nuke the whole directory, and things should work again.

这篇关于即使重新启动服务器,Rails开发环境也不会更新html / css / assets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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