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.
Related
So I install Ghost CMS and it is working great, but I noticed recently that the navigation settings (where I add new links to the menu and such) are acting strange and not working right.
So in the image above you will notice the ':80' port being added onto the domain. Which is fine I guess, but what is odd is that if i click out the field and then back into it it adds another port ':80' and continues to do that as many times as I click out, also if I tried to delete and save it immediately adds them back in. Look at Teaching and you will see what it ends up looking like.
Also when I go to the site front page and click one of the menu items I see a 404 error in the console saying the page doesn't exists.
I can't figure out what is going on it was working just fine a few weeks ago and I have touched anything on the server. I am stumped, I don't really know enough about Ghost so I am relying on a better expert to help me out here. I am using the Bitnami Ghost Cloud Image. and have the theme bleak installed.
Any Thoughts?
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.
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.
A website of mine is behaving weirdly. The layout sometimes is fine, and sometimes it is screwy. An example page that I see the problem on is this one: link
Disclaimer: I have yet to start my investigation into cause in earnest. I am turning to Stackoverflow because I am lazy and I hope someone will say "That happened to me once, it is probably this...". So please, no one get stuck into this working out this issue if it is something you have never seen before, as it wouldn't be fair as I have not done it myself.
Ok, some background:
The problem usually (maybe always) occurs when first viewing the page
The problem does not show up always, only sometimes
When the page shows up munged, if you refresh it usually reloads looking as it should
The site is a rails app
The css is passed through the neat Smurf Gem, which automatically minifies the CSS and Javascript on the page.
The layout problems happen in firefox (both linux and winXP)
The CSS is served up in the production environment using the ":cache => true" option which concatenates all the css files into one file
Anyway, I am hoping that this has happened to someone before and it will be really simple to fix. If not, I'll go and investigate and return with the solution (or a request for more help).
Thanks in advance!
James.
[edit]I added the first two bullet points, inspired by the comments and first answer[/edit]
We have had something similar when using HAML and SASS that resulted in the CSS being completely unavailable. It only happened on deploys. We determined it was a combination of the Rails stylesheet merging and the generation of the CSS from SASS. Sass was not done generating the CSS, which it did so on the first request to the application, when Rails attempted to merge it all together. The result, a corrupt useless CSS file. Then we stumbled upon this article which has a solution for preventing this issue.
Based on all this, my best guess is that the Smurf gem is attempting to generate your file on the first request, but Rails is serving it out before its done. The generation completes then each following request is fine. If this is the problem then the only solution i know of is to get the file generated before the first request. Of course, this does assume that it is related to deployments or application restarts in some way.
Peer
I had such a problem. The problem was only at the first time the page was loaded. Just reload it and it was fine.
The problem in my case was that the images where not there in the cache for the first time so the browser didnt know it's dimensions when preparing the page which caused the problem
If an image doesn't have a height/width assigned to it, a place is created on the page and it's put there. If the image doesn't quite fit, the browser may not know this until it's refreshed. Then it already knows the size and can properly fit it onto the page.
When I log in on my dev machine in an ROR application, I should be redirected to http://sitename/user/dashboard. This was happening successfully before, till I began developing on it :). Now it tries to go to http://sitename/user/images/navarrow, which results in the error ActionController::UnknownAction (No action responded to images).
I hadnt changed anything in the code except layout,views-level changes, no actions etc were changed. Then I reverted to a previous version to check, and it worked fine. I reverted back to my latest version and it again worked fine. So the problem doesnt seem to be in code, but somewhere else. I want to know why exactly this problem crops up every now and then. The fix is not hard, i just have to revert to a previous commit and then come back to latest commit, but I cannot figure out how it tries to redirect to a wrong url in the first place. Do I need to change some configuration to make it not happen again?
UPDATE: I had to work on the UI of the login form as well. Now when I created a login form with the required css, and tried to submit, this is what i get:
Parameters: {"format"=>"jpg", "action"=>"images", "id"=>"galway", "controller"=>"user"}
ActionController::UnknownAction (No action responded to images):
As you can see, I get another different faulty url, the prvious one had :id=>'navarrow'. SO I get the same error as above of a faulty url creeping out of nowhere! But wehn i go back and refresh, i discover that i actually am logged in, so the new login form is working as expected. i think if i commit my code now, and then go thru th process again, it will work again, but this bug is driving me crazy!
I think i figured it out partially. In the page, there were two images, entered like so:
<img src="images/nav_arrow.jpg".../>
<img src="images/galway.jpg".../>
So for some reason when a form got posted, and we were redirected to another page, somehow it also tried to map its request to controller/images/nav_arrow.jpg etc, and this was causing the unexpected behavior. But I still have to figure out why this error does not always crop up. I change image paths to absolute ones to make it work!
I'd check that you don't have something sneaking in .htaccess files to your directories (maybe one got accidentally checked in)?