Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Getting your Rails project online on a server

Noob question alert!

I've looked into Rail a bit and yeah it seems awesome but from someone coming from a basic PHP level how do I upload my files to work on a server? With PHP it's a simple FTP them across, link the database if it's needed then away you go.

Could someone give me the download on how I would move a project to work on a server.

Many thanks.

Ralph Johnson
Ralph Johnson
10,408 Points

The answers below work for Heroku, and I think it's a great tool for developers to test out their site in real-world conditions. What happens, though, when you get beyond testing, and want to deploy to a commercial host "for reals"? Are there any significant differences? How does git version control factor into that scenario? I'm trying to develop a site using MySQL, and have been shopping around for commercial hosts that already support it (of which there are several). Any differences there?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Why is Heroku only good for testing? It's a real commercial host, you just have to buy the proper package to support more traffic etc., like with any other host.

4 Answers

Stone Preston
Stone Preston
42,016 Points

I use heroku. Using git for version control makes deploying to production on heroku extremely simple. the only thing you might have trouble with is configuring postgres if you arent already using it but its not too bad

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I always remove the database.yml file from version control completely, in which case Heroku configures its own default file which works out of the box.

This is going to sound stupid but I always here the same thing when I mention uploading to a server.

What does Heroku actually do? Is it a server? I went to the site and granted I am properly knackered and can barely read but I just don't get it :/

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

It's a hosting service that allows you to upload Rails apps and make them work almost instantly if you follow their documentation. You just put your app into Git (if it's not using it already), you connect it with your Heroku account, push it and it will work online (you may need to migrate the database). So it's more than just a server. If you try to deploy a Rails app on your own, using a server that is not dedicated and pre-configured for Rails, it will probably be a lot more complicated than with a PHP app.

Ralph Johnson
Ralph Johnson
10,408 Points

My bad, sorry. didn't know. My only acquaintance was through tutorials.

Ralph Johnson
Ralph Johnson
10,408 Points

I've found servers that advertise RoR among their services, but once again confess that I don't know how difficult it is to configure, even if they say they support it. Also don't know anything about postgres--but I'm starting to realize that in today's environment you have to learn 3 new ways to solve the same old problems every day, it seems--sort of like working at the UN, where you have to learn the word for "dog" in Chinese, Urdu, Arabic, Portuguese, and Lithuanian (and remember which cultures expect you to bow, or to shake hands only with the right hand, or to belch after eating). After basic studies in Pascal, PhP, Javascript, jQuery, and Ruby, it's all blurred together into one long spiraling loop of the same basic concepts, just using different grammar and punctuation. Damn, it's hard to keep all that straight! $ signs, no $ signs, var and no var, semicolons or no semicolons, parens or curly braces or brackets, explicit or "relaxed" syntax, etc, etc. Still the same song and dance as it was with Basic, Fortran and Pascal, just different partners, slightly different capabilities and applications. Blurry. Used to hate throwing errors (not that it makes me jump for joy, but)--now I'm absolutely astonished imagining the man-hours of work that must have gone into generating all those error-trapping procedures, and the detailed messages, along with the suggested solutions, that actually help you get your junk to run.

Hi Suleiman -

When planning to deploy your Rails app, give some thought to the database you use in your development and test environments. The database you use for development & testing MAY affect your deployment. I learned the hard way that not all databases "speak" the same SQL language. There are database differences to be aware of.

Out of the box, Rails comes with SQlite3. It's already setup and easy to use, but if you create any "non-vanilla" database migrations you may run into problems when you try to deploy to Heroku or other non-SQlite host. This is particularly true if you have any "unusual" database migrations. Here's what I experienced.... While using SQLite in development & testing environments, I changed the type of a database column from "time" to "integer." After the local migration, everything worked great, but I hit a wall when I tried to push to Heroku, which runs PostgreSQL. Heroku took issue with some syntax in the migrations, and aborted the push. To solve the immediate issue and avert future problems, I converted my SQLite3 database to PostgreSQL. Now I use one database for all my Rails environments.

PostgreSQL can be a challenge to configure properly, but it works well, is powerful, and "plays nice" with Heroku. My advice: Consider developing and testing your Rails app in the same database environment that your host uses. You may not encounter any issues, but this is a heads up based on my experience.

Best,

Ronald