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

simon buysse
simon buysse
9,716 Points

Deploying a rails project on a webserver - information

Hi everybody, I just finished my first rails project (a blog site) and I'm trying to figure out how to put it out on the internet. I bought a Raspberry Pi 2, and have installed Ubuntu on it. I started out following a tutorial that uses pushion passenger and nginx to run my project, but started running into trouble almost immediately.

As I'm trying to solve these problems, I realize that I have no clue what it actually entails to deploy a rails project. For example I don't know what the difference is between production environment and development environment and how to use both environments. I also don't know what my options are to deploy a rails project. For example, could I just run rails server? I guess not, but again I don't know why not :)

Sadly I can't find anything in the library on deploying a rails project (neither do I find anything at codeschool.com), so I was hoping that someone here at the forum has a good source of information, or a very clear tutorial.

Thanks a lot!

1 Answer

Amy Kang
Amy Kang
17,188 Points

Development environment simply means the settings for your app for localhost. Production environment are the settings for you app after it's been deployed.

You can find information to deploy your app for free to Heroku:

https://devcenter.heroku.com/articles/getting-started-with-rails4

I'll give you a quick summary of what you need to do. Refer to page above if you run into problems.

Install the Heroku Toolbelt, and if you're using sqlite database move it inside a development environment block in your gemfile and any other gems you're using for development only.

group :development do
gem sqlite3
end

Add group production to your gemfile with the following gems.

group :production do
  gem 'rails_12factor'
  gem 'pg'
end

Now run bundle install. Create a Heroku account and login from your command line: "heroku login" Add, Commit, and push your app to a github repository from the master branch. From the master branch enter: "heroku create" Then push your app to heroku: "git push heroku master" Push your database schema to heroku: "heroku run rake db:migrate" Enter "heroku open" to open a window to the site. If you're having trouble with your app in production enter "heroku logs" and look for the error.

This is the quick and dirty run down of deploying a rails app. If you run into any problems google will help you out.

simon buysse
simon buysse
9,716 Points

Thank you for this Amy, Heroku looks like a cool solution, but is not really what I'm looking for. I bought this raspberry Pi with the sole purpose of hosting that blog site, so I'd love to run my own webserver. Plus I'd love to understand how the basics of deploying your app work.