无法在Rails中编辑或删除Javascript

时间:2013-05-23 06:42:58

标签: javascript ruby-on-rails-3.2

我对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动画看起来有点像文件存在时工作两次。当我完全删除它似乎只有一次动画。

1 个答案:

答案 0 :(得分:1)

您可能预先编译了资产,并且在开发过程中,它会加载两次,一次来自root / app / assets,第二次来自root / public / assets

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

config.assets.prefix = "/assets_dev

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

资源的网址将显示<link href="/assets_dev/bootstrap....,不会查看assets文件夹。