Introduction to Ruby on Rails

Introduction to Ruby on Rails
Difficulty: Moderate
Description: An Introduction to Ruby and Rails (continued)
Author: Founder; Date Added: 2007-06-29; Views: 8942

Part 4: Setting up your server

Welcome back, now that you know a bit about Ruby, it's time to get into Rails. If you are using RadRails as I suggested you can start up with everything you need including a server by going to File > New > Rails Project. From there, after naming your project you can browse to the server by visiting localhost:3000 by default the port can be changed by right-clicking on the server and selecting edit.


(click to enlarge)
Don't you feel like you've done something gratifying?

Part 5: Taking a look at the basics

I'm not here to show you how to create a whole web app here, I don't have the time nor the will to write a 600 page book. Instead, I'm going to show you how to get started building an application. For this section you're going to need MySQL 5 or above (http://dev.mysql.com/downloads/mysql/5.0.html), keep in mind that you can use whichever SQL server you choose (Postgre, Microsoft, etc.). MySQL is often the most widely used, but it may not be the best for you, I find Postgre to be the best alternative if you don't like MySQL's ways. MySQl's default user is rootp so for now, we'll be using root. Once again, this is all up to you.

Alright let's do things the simple way and go through the command-line. Type in: mysqladim -u root create railstutorial_development

You've now created a development server called railstutorial. Woot!

Alright, now we have to relate our database to our rails app. Open up the database.yml file in your project's directory it should be changed to look like:

Development:
adapter: mysql
database: rubytutorial_development
user: root
password:
host: localhost

The adaptor section, incase you were wondering, is what type of database you are using, it varies depending on your server of choice.

Now, let's test this database by typing rake db:migrate into the command line. Either, you get an error or you don't, if you managed to get an error make sure you follow all the steps correctly and retry them. If the error persists make sure your server is actually running and you are connected. In general the MySQL process (daemon) should run at boot time unless configured otherwise.

And now, you can combine the data in your database with the code you learned earlier. Rails really is that simple. I'm going to go let you play around now, I'm not putting any examples in here because examples only teach you what I can do, not what you can do. If you have any questions you can email me at my anon address: winpwnd [at] gmail [dot] com, or post in the Web Design section on the Gamexe.net forums.

Although this tutorial was entirely written by me, I don't claim copyright to any of it. If you decide to modify it let me know first, and at least give me credit. If you see someone using this document without credit given please give them a stern talking-to (yeah right!) and email me at winpwd [at] gmail [dot] com.