localhost:3000 won't update after saving changes in sublime - ruby-on-rails

I'm new to programming and trying to make changes to a Rails app. I downloaded a forked repo from Github and got it up and running on my local computer after running rake db:migrate (originally got error messages).
I've since made changes to a few HTML files (minor - changed text of a few sentences) in Sublime and saved, but they aren't reflected in browser.
I refreshed the browser and tried restarting the server. I must be missing steps. Any help appreciated, thank you.

There are a few things that could be happening. Most likely, you are getting some browser cache( but you could be getting a network, web server cache as well)
Try reloading the page with ctrl + r ( or cmd + r if you don't like real nix)
Next you could try loading in an incognito window to see if it's a session level issue.
Next you can try restarting your server. In general in development environment there shouldn't a cache set up but maybe you are hitting an issue there.
In my dev config, I have all the caching off. In my dev browser I have all the dns/browser caches disabled.
At the end of the day, you could be modifying the wrong file. Try ack'ing or grepping to see if there are other occurrences of that text in other files. Often there will be multiple header partials or multiple layouts that are similar but not really.

Related

Not able to clear development log file when server running locahost

I am facing weird issue, where I am unable to clear development log file contents while server web-brick up and running.
But same works fine in sublime text 2 editor ie. Clearing of development log file. This issue forcing me to restart server each and every time when I have to clear logs.
Kindly help me to avoid restarting for clearing logs. If any suggestions for workaround appreciated.
EDIT :
Observed issue with platforms windows 7 64/32 bit , windows 10 64bit(Checked on only these).
I have opened same log file with ST2 and ST3.
And tried to clear log file in ST2 and ST3, got alert message only in ST3.
For me it seems, its issue with Sublime Text 3, which is not allowing clearing of logs if used by other process.
EDIT 2 :
This is exactly the issue, I am facing right now.

Images disappear on refresh in heroku-hosted rails application

Let me say first that I'm quite new and inexperienced with rails. Today I tried to update an image in a rails app hosted on Heroku. Anyway, this is the simple flow I followed as I did other times before:
Add updated image to the image folder
Precompile the assets rake assets:precompile
Add and commit all changes
Push to heroku
Until this point all seems fine: I open Chrome to check my app from my domain and it's all there as expected.
The problem is that if I refresh the page all the images disappear (like they have never been loaded). This does not happen locally.
If I do a ctrl+f5 it all comes back nicely, but I lose everything again on simple refresh.. and so on.
Has anyone experienced something similar? I understand this might be hard to answer as there is not much code to show. Let me know if I can give more details.
On a final note, it seems that all works normally on a friends machine (that is, refresh doesn't give this problem). I'm thinking something might be wrong with my Chrome settings here? I don't remember having changed anything recently though.
This is very weird and quite annoying some help/insights would be great.
UPDATE: This seems indeed really to happen locally on my machine at work. I checked from another couple of computers at home and the app is displayed fine (without any refreshing problem).
Did you check if the cookie is disabled by your browser for the heroku website in particular?
I have just tested this issue with an image based website (https://unsplash.com/). When the cookie is disabled for that website, pressing F5 clears all the images, while pressing Ctrl-F5 brings those lost resources back as like as your case.
Enabling cookie resolves the issue in my case.

Docker reload does not reflect changes in CSS files

I've configured docker to reload automatically when i make changes to my project files. It works fine when i make changes in HTML or .py files but does not reflect any changes to CSS files. this question has also been asked here but there is no answer yet. Please help!
I'm using Flask python with gunicorn. Exactly following this course on udemy.
Figured that this error is unpredictable. Its a problem with virtualbox used by Docker. The simplest workaround i found was to run another parallel application which apparently resets virtualbox. Clearing browser cache after doing that solved the problem for me.
While this is just a workaround, if anyone has a clear solution, please share it here.
I had the same problem and solved it using this suggestion by #famelis:
The problem, IMHO, is with the browser. It is using the cache for css and js.
If you are in development environment you can use google chrome and open the programmer's tools (Ctrl+Shift+I)
Then in the Network tab the "Disable cache" must be checked, and this solves the problem.
In production you need to have different paths/names for the files, possibly with version number, for the browser to re-read the files and not use the cache.

Rails public files only showing with cookie on Heroku

Recently I've run into the issue that the public files of a rails application only load if there is a cookie present. I originally noticed this because Google reported that it couldn't find our robots.txt file. Later I realized that it seems to apply to all of our public files for some reason.
For instance, upon visiting this site, the content is blank. http://80000hours.org/robots.txt
(If it's not blank, remove the cookies from the website).
However, when I load the main page at http://80000hours.org/, and then go back to /robots.txt, the page loads correctly.
I'm quite confused what could create this issue and how to go upon debugging it. Looking back on my commits it doesn't seem like I changed anything substantial during the period where it broke. The Memcache add-on for the website shut down around a week before this happened; I never set up a replacement, but wouldn't think this would have caused the issue.
The issue also does not exist locally, only on the production and staging Heroku instances. The full codebase is here, the issue occurred around November 14th.
Any advice is much appreciated.
Sure enough, it was Memcache. I added the new Heroku Memcache add-on service, Memcachier, and it worked fine without the cookie. I'll check tomorrow if Google successfully find the /robots.txt file or not, but I'm assuming it will.

rails view not updating

I have started with my first rails project using Redmine. I have started to dig into the code to get a better idea and having a hard time understanding the erb files. When I go to make a simple change to the welcome.html.erb file, I make the change and check in the browser and there is no change. Once I save a file is there something that I need to run before the view will be updated? I did not think so, but that is why I am here asking because the view will not update the page when I save the file.
Thank you in advance for any help.
UPDATE: After I update the .html.erb file and open it up again in vim, my changes are still there. Only problem is that the page does not reflect what the change has been made to and when I view source it is not there either?????
It looks as though my cloud server is slow to update the pages so I need to check and see why this is. There is no problem with the pages when working locally and the page was updated in the source the next morning.
Using an IDE is not a good idea when you're learning Rails.
Try opening a console and cd into your application directory. Then run rails s and you should see your application running on a browser when you point to localhost:3000
You can leave the server running and modify your view file with any text editor. Changes should reflect automatically without even need to restart the server.
HTH!

Resources