I would appreciate any feedback regarding what may be causing my issue, described below.
I have an application that allows users to upload images. Everything works fine in development and used to work fine in production.
Recently, my newer images have all broken. I can upload new images, but when I check back a few hours later, the images are broken again. This started happening about a week ago, and images that I've had up in production from before then are still ok.
I am using Rails with Bootstrap and SimpleForm, and using Paperclip for the images. I am using Postgres in both devleopment and production, and am deploying to Heroku.
The only hint I have is in the "blank_profile_pic.png" image that I use as a default when users don't have a profile picture uploaded.
User.all.each do |u|
if u.profile_pic.file?
image_tag(user.profile_pic)
else
image_tag("blank_profile_pic.png")
end
end
For users that don't have a profile_pic uploaded, a broken image appears if their profile was created in the last week, but the expected "blank_profile_pic.png" remains for people that created their account before the issues started surfacing a week ago. How can the same block of code return different results between recent and older users?
I really don't know where to start with this, so would appreciate any feedback regarding what possible causes could be, and if there are any other files that I can show here.
Thanks very much for your help!
Heroku is a read only system. So you most definitely have to upload your images either to S3 or some other cloud provided.
Your images might have been uploaded to /tmp in Heroku and then somehow it was cleared, hence the errors.
Here are the docs: https://devcenter.heroku.com/articles/read-only-filesystem
And configuring Paperclip with S3: https://github.com/thoughtbot/paperclip#storage
I am not sure if you have the imagemagick gem installed, but we had same issue with image_magic that was breaking our paperclip functionality in production, but not in development (weird, I know). Yet even after removing imagemagick from our gemfile and Gemfile.lock locally (running bundle install and all that stuff) and then deploying back to production on heroku, the error persisted in production! (weird, I know).
What ended up doing the trick was running:
$ heroku repo:purge_cache -a myAppName
(Taken from: https://github.com/heroku/heroku-repo#purge_cache)
When you deploy your app, Heroku caches some things like your assets and installed gems in order to speed up deployment. Although this is a great feature, it can have side-effects sometimes, and in this case, it seems that something about the imagemagick gem got "stuck" in production's cache, which is why purging solved the issue for us (since after purging, your app will rebuild itself from scratch on your next deployment)
Related
I am using Heroku to try to deploy a personal Ruby on Rails project and everything was going great until today.
I am very very new to Ruby on Rails and Heroku so please bare that in mind. I am not sure what is causing my issue and therefore not sure what code or information is best to supply so please ask me what you think you need to know to help resolve the issue and I will provide it.
My Ruby on Rails app worked fine both locally and on Heroku until I followed the information here to try and serve static images from Amazons S3 bucket. Note I only went as far as the static assets section.
This appeared to stop my Ruby on Rails application from recognising changes in my code. So I would make a change to a HTML file in my editor but the server was serving up the older version of the HTML file, even restarting the server didn't fix this.
I have been searching the web for hours trying to figure out what has gone wrong.
I deleted everything under public assets and I ran the precompile command:
rake assets:precompile
And this seems to have improved things locally, when I edit a HTML file the changes are reflected on localhost. However when I push to Heroku and go to my application hosted on Heroku it still shows the older HTML file no matter how many changes I make and pushes I do to Heroku.
The HTML files that are not updating are located here:
app/assets/templates
I'm not sure what I may have changed that has caused the HTML files not to get updated on Heroku?? What should I look at and try? What other information would be useful in helping track down the issue?
The answer marked as correct in this StackOverflow question worked for me - Updated CSS Stylesheet not loaded following deployment to Heroku? - It looks like I accidently added assets precompiled file in my git repo somewhere along my development and that caused the issue.
I am trying to deploy an ecomm site I am developing to Heroku.
I am using Rails 4, Spree 2.1 with the Spree_Fancy theme overtop that, S3 for images, and postgres as database in all environments.
The application is working perfectly on my local machine, but when I deployed it to Heroku, the front end breaks. The app runs via Heroku, but there is no styling at all, no theme, nothing. Just plain text and "no products found" message.
I expected there to be no images (since none had yet been uploaded to s3), but there were no products either, even though the db migrations ran.
Any ideas of what I am missing?
I've just answered on another thread the same problem scenario. Hope it helps.
Broken spree_fancy layout on heroku
I'm working on an app with a friend and I keep running into errors in my local environment but the app works online (using Heroku). I believe memcache is causing issues in my local environment. Here's what I've done so far:
Added the memcache add-on to my app in Heroku
Installed Homebrew on my machine
Installed memcache using Homebrew with brew install memcached
Then I've restarted my app and ran the memcache process with memcached -vv.
When I access the app it works fine. Then I'll create a record. This also works fine. Then on page reload - when the record is fetched from the cache, the entire app systematically fails. Below is the error I receive (although I'm not sure how much help it is)
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
The error(s) only point to code where memcache is used. A simple user action (i.e. buy a book from a company) triggers the error and once it occurs the entire app is broken (meaning any route leads to the same error). It seems as though its just not storing/fetching the item, which makes me think the app isn't hitting memcache at all...Is it possible I have to gem install something - even though this is working in the production environment and on another dev's machine?
I'm looking for any guidance with troubleshooting memcache. More specifically, has anyone ever run into issues with local vs. production environments in regards to memcache? Any suggestions? I've thought about removing memcache from the app on Heroku, then un-installing it on my computer and then redoing everything.
I know I'm being fairly vague here but I'm not exactly sure what code to post that would help.
Thank you for any help.
After much frustration I began retracing the steps I took to install and implement memcache on my local environment. It didn't make sense how it was working online and with my friend's environment but not mine. Eventually I ran bundle install and then restarted the app and ran a new memcached process and that fixed everything. I'm still a bit confused but I guess my Gemfile just wasn't updated (even though I could've sworn it was).
I use memached without any problems in my environmens, though I do not use Herouku. To access memcached, I have installed the Dalli gem from https://github.com/mperham/dalli
Using it is rather simple.
In the file environment.rb add:
DC = Dalli::Client.new('localhost:11211')
In the application I use
DC.get(key)
DC.delete(key)
DC.set(key,value)
You will first need to test if the keys you're setting are actually getting set or not. You can use Memcached via a Telnet interface to test this.
We decided to try using RefineryCMS for our current project and have run into some issues.
We began the project in a local development environment. The deadline is very quickly approaching. At first, we tried to move the project into production using a DreamHost server. There were issues with the images (Refinery uses Dragonfly), where our database dump wasn't brining any images over (or thumbnails).
We have exhausted our resources and still can't find a solution to our problem. I've done research, asked in the Google group, emailed people, and asked in the chat - no one has answered yet.
So, does anyone here have any idea what is the best solution for moving a project over from a local development environment to production?
I am sure I can't be the only person who has run into this issue...
Thanks in advance.
In case someone arrives here with this same situation (as I did), my two cents:
I've successfully migrated between servers by dumping the database and copying public/system, so this is perfectly feasible and straightforward.
At first the images were not showing neither in the backend nor in the frontend, but after a couple of hours stuck I realized the problem was that I hadn't installed ImageMagick in the new server (huge facepalm).
A quick sudo apt-get install imagemagick solved the issue.
Of course, YMMV, but I hope that helps.
I'm not sure what version of RefineryCMS you are using, or how you configured it, but unless you chose to use Amazon S3 for uploads then your Dragonfly images and resources are being stored on the file system. So in addition to that database dump, you'll probably want to look in the public/system/ folder and copy everything in the images and resources folders up to the server too.
I have some apps running on Heroku. I will be upgrading my OS in two weeks. The last time I upgraded though (6 months ago) I ran into some problems.
Here's what I did:
copied all my rails apps onto DVD
upgraded OS
transferred rails apps from DVD to new OS
Then, after setting up new SSH-keys I tried to push to some of my heroku apps and, whilst I can't remember the exact error message off-hand, it more or less amounted to "fatal exception the remote end hung up"
So I know that I'm doing something wrong here.
First of all, is there any need for me to be putting my heroku hosted rails apps onto DVD? Would I be better just pulling all my apps from their heroku repos once I've done the upgrade? What do others do here?
The reason I stuck them on DVD is because I tend to push a specific production branch to Heroku and sometimes omit large development files from it...
Secondly, was this problem caused by SSH keys? Should I have backed up the old keys and transferred them from my old OS to my new one too, or is Heroku perfectly happy to let you change OS's like that?
My solution in the end was to just create new heroku apps and reassign the custom domain names in heroku add-ons menu... I never actually though of pulling from the heroku repos as I tend to push a specific branch to heroku and that branch doesn't always have all the development files in it...
I realise that the error message I mentioned doesn't particularly help anyone but I didn't think to remember it 6 months ago. Any advice would be appreciated
PS - when I say upgrade, I mean full install of the new version with full format of the HDD.
One of the reasons for using a (D)VCS (Version Control System) is reproducibility (usually "reproducibility of builds", but here also the ability to reproduce a given state of a system versioned at a given time)
So it could be a good test to see if you have:
all your system properly committed
all the process to regenerate the extra content (if need be) you need from your restored data
Making a bundle of your repo (meaning dealing with only one file to backup somewhere else, DVD or otherwise) is a good start.
And regarding your "hung up" error message, if SSH is involved, that means you need also to save SSH keys (see comments) usually located under the user's homedir (as in ~/.ssh/authorized_key)