I've been searching and doing my research but I can't seem to find any articles directly talking about this. I have an art gallery rails app with around 6 models of different attributes, pieces of art, etc. When I make changes to their site and redeploy, will the databases also be reset? Or is Postgres and the rails app separate on Heroku?
I also read that someone takes all of their data and puts it into seed.rb then repopulates the databases with the seed data once it's redeployed? Does that sound right? Any insight would be very helpful. Thank you
If you're using a database, your data won't get lost on redeploys. Only the data which is stored in /tmp gets lost after a deploy is performed.
I'm going to assume you're using heroku postgres. In this case check out this, it's good to regularly create backups: https://devcenter.heroku.com/articles/heroku-postgres-backups
In seed.rb you should only add data which is necessary to set up the project, and nothing more. e.g. create an admin.
No data will be lost on redeploy to heroku until you intentionally do so.
Seed data only for populating some default database values in a rails application.
I am assuming you are uploading pictures in your application and they don't persist after deploy. So that true. Heroku does allow you to upload images to heroku. But they not persist after deployment.
Uploaded images persist for particular interval of time.
If this is the case with you try upload images to amazon s3 bucket, all uploading gem support that.
Related
I use Aiven.io to manage a PSQL server, inside has multiple databases! Im using it from my rails app, so my rails app uses xxx_production, xxx_development etc.. But i dont remember creating xxx_optimization or metrics databases. The metrics one in particular is 50GB (My xxx_production is only 11GB so this is costing me a lot of extra money)
Is there any way to figure out who created these or why? My suspicion is there is some GEM im using in my rails app that could have created it to keep track of things? No idea what these databases are, and i would delete them but I do want to know what they are so i make sure im not breaking anything.
Thanks!
I'm getting really close to putting up my first app. However, I'm worried that because I'm so new, I won't know how to manage my database properly.
What's the best practice for managing a database on heroku? As in, backups for example. What if I really screw up something? Can I edit information like usernames, email addresses for users, etc directly in heroku or do I still do that from my terminal?
As Gene mentioned above, you will use pg backup to back up your db. You can do this manually, but you can also schedule backups.
You can easily access the rails console on heroku. Docs here: https://devcenter.heroku.com/articles/getting-started-with-rails4#console
Gook luck rolling your your first app!
I have two heroku applications, staging and production. As the names would suggest, we use the staging app for testing/new code. Once we deem that it's relatively bug free we move it to production.
The one thing this doesn't translate to is data. We might add a bunch of data to staging to see how it looks, then have to do it again in production to for the general user to see it.
For example, we have a news reader which pulls in stories from many different RSS feeds. Say we add 20 Feeds to staging and decide that they're all good for production. Is there any way to wright a method that connects to the production database from staging and adds each feed? I'm aware that there are ways to do this by overwriting the whole database but that doesn't work here since user specific data in production would be deleted.
I like to use heroku and paperclip for image uploads. Usually my users don't need to upload many images.
I'm now embarking on a website where many users will be trying to upload images at the same time. Unfortunately on heroku, it seems I need a separate dyno for every image upload, otherwise the site becomes unresponsive. Or am I missing something?
What is an optimal way to set up a rails application (not necessarily on Heroku) where the site can easily deal with (in a scalable way, ideally) multiple uploads at the same time?
This is a shortcoming with Heroku - it doesn't handle file uploads very efficiently. See this article that discusses this point, among others. The author suggests using the carrierwave_direct gem or the Cloudinary service. Neither concept will work well for Paperclip as it doesn't provide cloud storage support. You might want to move to CarrierWave for easier implementation of these concepts.
I've only just started learning ruby on rails and I would like to create an application that will allow me to add files to the database. Currently, I'm developing the rails application using the Aptana plugin for Eclipse and the application is using the default sqllite db.
I have tried generating a scaffold with the following parameters: documents title:string file:varbinary. Then I do a 'rake'->'db'->'migrate'. When I migrate to localhost/documents and click on 'New Document' the application fails and displays an error.
What I would like to do is click on 'New Document', have a field that will allow me to browse for a document on my local computer, select the document and add it to the db on the rails application.
Paperclip is more recommended than attachment_fu these days. It is really simple and easy to use with your active record model.
Is it a particular kind of file you want to add?
I just ask because if it's not data of a kind that benefits from being in a database ( textual data might be searchable, binary data is not ) then you are much better storing it in the filesystem and serving it up straight - especially for stuff like images or video - rather than inserting it into a database and having to go through your application every time a user requests it.
I'm not saying that there aren't any reasons you might want to have a file in the database, but I treat that as a last resort and in ten years of web programming I've not come across a case where it was necessary.
I would highly recommend the attachment_fu plugin as this lets you create models with attachments pretty nicely, Paperclip plugin is another good one also!
If you have trouble deciding which one to use, as far as i can remember, Paperclip makes it easier for multiple attachments, such as an Album has many Photos, and Attachment_fu is easier for single attachments such as a User has one display picture.
We do something like this on a site I'm managing. Instead of storing these files in a database, I'd agree with the other posters here and recommend you try something like Paperclip.
One caveat: if you want access control, make sure that paperclip doesn't save your files somewhere under /public, where anyone could possibly access them if they knew the URL. Deliver files to the user via send_file in your controller.