问题
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