1

我对 Rails 3.2 有一个非常奇怪的问题。我对“app/assets/javascripts”所做的任何编辑都不会对我的应用产生任何影响。我什至从该目录中完全删除了所有文件,并且脚本(应该已经消失)继续像以前一样运行。

这是我从“app/assets/javascripts”中删除所有 js 文件后的服务器日志

Started GET "/article/4" for 127.0.0.1 at 2013-05-23 15:37:55 +0900
Processing by ArticleController#show as HTML
Parameters: {"id"=>"4"}
  Article Load (0.1ms)  SELECT "articles".* FROM "articles" WHERE "articles"."id" = ? LIMIT 1  [["id", "4"]]
  VocabularyWord Load (0.2ms)  SELECT "vocabulary_words".* FROM "vocabulary_words" WHERE "vocabulary_words"."article_id" = 4 ORDER BY word
  CultureNote Load (0.1ms)  SELECT "culture_notes".* FROM "culture_notes" WHERE "culture_notes"."article_id" = 4 ORDER BY title
  Rendered article/show.html.erb within layouts/article (1.2ms)
  Rendered layouts/_footer.html.erb (0.7ms)
Completed 200 OK in 15ms (Views: 11.9ms | ActiveRecord: 0.4ms)


Started GET "/assets/normalize-2.1.1.css?body=1" for 127.0.0.1 at 2013-05-23 15:37:55 +0900
Served asset /normalize-2.1.1.css - 304 Not Modified (0ms)


Started GET "/assets/sez_core.css?body=1" for 127.0.0.1 at 2013-05-23 15:37:55 +0900
Served asset /sez_core.css - 304 Not Modified (0ms)


Started GET "/assets/article.css?body=1" for 127.0.0.1 at 2013-05-23 15:37:55 +0900
Served asset /article.css - 304 Not Modified (0ms)


Started GET "/assets/Acknowledgement-webfont.woff" for 127.0.0.1 at 2013-05-23 15:37:55 +0900
Served asset /Acknowledgement-webfont.woff - 304 Not Modified (0ms)

如您所见,javascript 资产没有被提供,但它们继续在应用程序中运行。这是怎么回事???

我尝试清空浏览器缓存,但没有帮助。

还有一件事。当文件存在时,我想要编辑的 javascript 动画看起来像是在工作两次。当我完全删除它时,它似乎只动画一次。

4

1 回答 1

1

您可能已经预编译了资产并在开发中加载了两次,一次来自 root/app/assets,第二次来自 root/public/assets

但是假设您希望能够预编译资产(以在将它们部署到服务器之前测试它们是否会被编译)并且不想在每次进行预编译时都删除它们,您可以重命名预编译资产文件夹的前缀和:

config.assets.prefix = "/assets_dev"

把它放在你的 development.rb 中,你可以运行 assets_precompile 但它们不会加载到应用程序中。

资产的 URL 将显示<link href="/assets_dev/bootstrap....并且不会查看assets文件夹。

于 2013-05-23T07:31:46.457 回答