27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Deploy away!<br />

Create the database and the user in PostgreSQL with the same name so that when the<br />

system user account of ticketeeapp.com attempts to connect to this database they are<br />

automatically granted access. There is no need to configure this at all, which is most<br />

excellent. This process is referred to as ident authentication.<br />

14.4.2 Ident authentication<br />

Ident authentication works by determining if the user connecting has an account with<br />

an identical name on the database server. Your system’s user account is named<br />

ticketeeapp.com and the PostgreSQL user you created is also named ticketeeapp.com.<br />

You can attempt to connect using the psql command from the ticketeeapp.com user,<br />

after first exiting from the postgres user’s session:<br />

exit<br />

sudo su ticketeeapp.com<br />

psql<br />

If everything goes well, you should see this prompt:<br />

psql (8.4.8)<br />

Type "help" for help.<br />

ticketeeapp.com=><br />

This means that you’re connected to the ticketeeapp.com database successfully. You<br />

can now execute SQL queries here if you wish. Exit out of this prompt by typing \q<br />

and pressing Enter.<br />

That’s all you need to do for your database for now. You’ve got a fully functioning<br />

server, ready to accept your tables and data for your application. Now you need to give<br />

it what it needs! You can do this by putting the application on the server and running<br />

the rake db:migrate command, which will create the tables, and then rake db:seed,<br />

which will insert the basic data found inside db/seeds.rb.<br />

We’re not going to make you manually copy over this application, as this can get<br />

repetitive and boring. As programmers, we don’t like repetitive and boring. One of<br />

your kind is called Jamis Buck, and he created a little tool called Capistrano to help<br />

automate the process of deploying your application.<br />

14.5 Deploy away!<br />

Capistrano is a gem originally created by Jamis Buck that is now maintained by Lee<br />

Hambley and additional volunteers, as well as the growing community that use it. It<br />

was initially designed for easy application deployment for Rails applications, but can<br />

now be used for other applications as well. Capistrano provides an easy way to configure<br />

and deploy versions of an application to one or many servers.<br />

You’ll use Capistrano to put your application’s code on the server, automatically<br />

run the migrations, and restart the server after this has been completed. This action is<br />

referred to as a deploy.<br />

Before you leap into that however, you’re going to set up a deploy key for your repository<br />

on GitHub.<br />

395

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!