Rails 101: Introduction
December 28, 2008

So you want to learn Ruby on Rails? Whether you are comfortable with programming or new to writing your own applications and websites – this guide is for you. This is the first article of many where we will cover everything you need to know to get to grips with programming and building your own web applications with Rails.
We won’t be starting with building a fully blown social network application to rival Facebook or anything of that sort, so don’t worry about being thrown in at the deep end – we’re taking this one slowly.
You can download a video version of this article, however the article covers the topic in a greater depth.
Agenda
Getting started is always the hardest part, so we thought we’d outline a little description of what this article, and subsequent articles, will cover before you commit your time to them.
In this first article we will look at what Rails is, why it came to be, and some concepts you should know about.
Future articles will focus on individual aspects of Rails to develop a deep and broad understanding of how everything works and how it can be moulded to your advantage.
Background
Web applications
So why would you want to write an application? Well as just mentioned: most websites are run from web apps of some description. Many believe “web 2.0” to be the new fad, however it really translates to user-generated content, which we’ve had for years, what do you think the first bulletin boards contained?
SaaS is becoming a popular means of businesses starting up with minimal costs, rather than needing expensive email & workgroup servers, they can use Google Apps, instead of expensive Sage licences, we are beginning to see LessAccounting accounts, the list goes on. If you can develop something that solves a problem for yourself, others are likely to have the same problem, and you should rightfully be able to monetize upon that.
Ruby on Rails
Rails was originally produced as a tool to fulfill the needs of 37Signals in their development of BaseCamp, however after Rails became public it has quickly become one of the best tools for web development.

A main point to grasp is that Rails is not a programming language, but a framework for quick and easy development of web applications, built on top of Ruby (which is a language), hence the name Ruby On Rails. You shouldn’t worry if you don’t know Ruby, or don’t know how to program Ruby I’ve written up an article on The Very Basics of Ruby I suggest you read before continuing.
What sets Rails apart from other frameworks is it’s agile mindset, opinions and paradigms – rather than trying to suit everyone it has focus. Rails employs the idea of convention over configuration whereby it uses defaults for most of the development, usually these defaults will be exactly what you want, but you will still be able to override them if you need something else.
Installation
Ruby
I won’t cover installing Ruby, as I’ve briefly described them in my guide to the basics of Ruby.
Rails
To run Rails you must first have Ruby installed and RubyGems, then it is as simple as: gem install rails
Once you have Ruby and Rails installed, you can start your journey to making millions in the next world-changing web application.
Suggested applications
For Mac users you are lucky as you can use TextMate, quite possibly the best text editor ever invented, however all you need to code Ruby is a text editor (even notepad would do) and a command line interface (terminal, console or command prompt).

Ideas & concepts in Rails
Generators
Rather than creating loads of files manually, Rails builds in generators which create sets of files based on options that you provide. This can mean that you can create a basic application with no code whatsoever!
Model View Controller
Rails is a fully-fledged MVC framework, so your HTML (views) is separate from the data objects (models) and the code which makes changes to such objects (controllers), this keeps everything neat and tidy so you don’t have to dig around to find what you’re looking for.
Currently, the general consensus is that you should have so-called skinny controllers having most of the logic in the models, because the skeleton for controllers is produced in the generators, so keeping them as standard as possible leads to much easier maintenance.
RESTful API
By default, Rails is setup to use the REST protocol as an API to allow other applications to integrate with your own.
Simple routing
Following on from the RESTful API which relies upon URLs and HTTP request methods, it would be a pain to setup these routes manually using .htaccess files and the like, so Rails takes away all this pain by allowing you to specify routes in a Ruby file, but they’ll be covered in a dedicated future article.
Object-Relational Mapping
ORM is a programming technique that links your classes to tables in a database, so you have to write little or no SQL. Rails defaults to SQLite for quick development, but also has adapters for databases such as MySQL.
Where to go for help
The Rails community is going strong and there are hundreds of places you can find help, checkout the official RubyOnRails community page, RailsForum, or you can even leave a comment below!
Read the next in the series: File Structure »
2 people have voiced their opinions, voice yours?
Mr. Jar said:
Thanks Ryan for this screencasts, really, I’m very happy to learn Rails with ur screencasts, i use TextMate as editor.
I wait next episodes.
regards.
Edit | Destroy
João said:
Realmente muito bom o texto continue assim
Edit | Destroy