2

So I've got my web app running fine, I've had to update my JavaScript file for a certain reason. The JavaScript has been updated and pushed up to my server however isn't actually updating on my server.

I've made a link URL change but the URL hasn't updated. I've cleared my cache etc and it hasn't worked.

I'm not 100% sure why its not updating, I have no idea what code you need form me, I've ran multiple compiles, The JavaScript file in question is listed in assets.rb and doesn't update

Anything I can do to get this to update?

Sam

RPichioli
  • 3,245
  • 2
  • 25
  • 29
admitme_sam
  • 159
  • 10
  • if it's javascript, why is the file name `assets.rb`? `.rb` is a ruby file – davidhu Sep 21 '16 at 20:17
  • Sorry the js file is listed in the assets.rb file – admitme_sam Sep 21 '16 at 20:23
  • To every sentence in your question I have to ask: 'How?', which will probably lead to 10 more follow-up questions. You need to be more specific. Where you run the server, what server, how you "push" code, etc? Otherwise it's impossible to answer – Mike Szyndel Sep 21 '16 at 22:03

3 Answers3

1

Going out on a limb here. It sounds like you're precompiling your assets and then pushing them to your server. That's fine except whenever you make changes to those files the asset pipeline will change the URL of the new asset. So it keeps referencing the old URL instead of the new ones.

If this is the case, you need to clean or clobber the URLs depending on what version of Rails you're using.

Rails 3:

rake assets:cleanup

Rails 4:

rake assets:clobber

You can read more about it here:

Confusion about rake assets:clean / cleanup on the asset pipeline in rails

Community
  • 1
  • 1
Michael Heath
  • 174
  • 2
  • 11
0

You may need to precompile your assets in order for them to update. Try running rake assets:precompile and then re-deploy to your server.

jackerman09
  • 2,492
  • 5
  • 29
  • 46
0

I am having same issue with Rails 6 and Rails 7 app in development environment. For example, I add console.log into the javascript controller, but it won't log anything as if it is not there. Based on trial and error and found out that running following three commands in the same order usually resolves this problem, usually for some time, and then it re-appears again

rails assets:clobber
rake tmp:cache:clear
rake assets:precompile
msuliq
  • 150
  • 1
  • 12