Can't Edit Or Delete Javascript in Rails

微笑、不失礼 提交于 2019-12-13 01:44:02

问题


I'm having a really weird problem with Rails 3.2. None of the edits I make to 'app/assets/javascripts' has any effect on my app. I even completely removed all files from this directory and the scripts (which should have disappeared) continue to function like before.

Here are the server logs when I've removed all js files have been removed from 'app/assets/javascripts'

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)

As you can see, the javascript assets are not being served and yet they continue to function in the app. What's going on???

I tried emptying my browser cache but that doesn't help.

One more thing. The javascript animation I want to edit kind of looks like it's working twice when the file is present. When I completely remove it appears to animate just once.


回答1:


You might have the assets precompiled and in development it loads twice, once from root/app/assets, and the second from root/public/assets

but let's say you want to have the ability to precompile assets (to test if they will be compiled before deploy them to server) and don't want to bother deleting them each time you do precompile you can rename the prefix of the precompiled assets folder with:

config.assets.prefix = "/assets_dev"

place this in your development.rb and you can run assets_precompile but they won't load in application.

Urls for assets will show <link href="/assets_dev/bootstrap.... and will not look into assets folder.



来源:https://stackoverflow.com/questions/16707218/cant-edit-or-delete-javascript-in-rails

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