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

3
  • if it's javascript, why is the file name assets.rb? .rb is a ruby file Commented Sep 21, 2016 at 20:17
  • Sorry the js file is listed in the assets.rb file Commented Sep 21, 2016 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 Commented Sep 21, 2016 at 22:03

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

-1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.