Ruby on Rails (sometimes RoR) is the most popular open-source web application framework.
It’s built with the Ruby programming language.
You can use Rails to help you build applications, from simple to complex, there are no limits to what you can accomplish with Rails!
What is a framework?
A framework is a collection of code, tools & utilities that give you a specific structure to work with when you’re writing software.
This structure makes your code more organized.
Your work becomes easy when you learn to use it correctly.
What Does Rails Do Exactly?
Rails helps you build websites.
The kind of websites that you use every day.
Sites that allow you to log in, leave comments & reviews, make purchases…
Rails is made from several components to facilitate this.
For example:
Active Record helps you read, create & update records in your database without having to be a database genius.
While the routing mechanism allows you to easily map URLs (like /login) to specific actions.
If you had to code all of this from scratch, without a framework, it would be a MASSIVE amount of work.
But Rails handles all of these details for you…
So you can focus on building your own applications!
Examples of Ruby on Rails Applications
Who is using Rails?
What are some examples of Ruby on Rails sites?
Here are some:
Github
Shopify
Ask.fm
Kickstarter
Scribd
ConvertKit
Twitch
Instacart
Zendesk
SoundCloud
These are not small companies!
And all of them benefit from using Ruby on Rails to serve their customers.
Should You Learn Rails?
If you’re looking for a challenging, fun & creative career building amazing websites that help people, then Ruby on Rails may be for you.
Anyone can learn Rails, even if you don’t have programming experience.
It may take more or less time depending on where you are.
But every skill CAN be learned & mastered.
The benefits of using Rails:
It’s an integrated solution. Rails gives you everything you need to create a web application.
Rails conventions & default configuration saves you a lot of work!
Rails has a great ecosystem so you can find all the tools & support that you may need
It’s under active development, so you get fixes & new features on a regular basis!
And the best reason of all:
“You get to use Ruby which remains the most extraordinarily beautiful and luxurious language I’ve yet to encounter” – DHH, creator of Ruby on Rails
The Rails Philosophy
Ruby on Rails is an opinionated framework.
One of these opinions is that convention should be more important than configuration.
What does that mean?
It means you have to make less decisions because the creators of Rails already made them for you.
Because you have to make less decisions you’ll be more productive & gets things done faster.
But if you want to change some of these, you can.
What are some examples of convention over configuration?
Rails looks for specific file names when looking for your code.
For example, if you have a Book model, Rails will look for a file named app/models/book.rb.
This is the convention.
Instead of having to say:
“Hey Rails, this is where to find this file”
Rails tells you where it should be.
A Ten Thousand Foot Overview Of Rails
How does Rails fit in the big picture of a complete web application?
I drew something for you:
Rails receives requests, routes them to the appropriate action, which then interacts with the database (via ActiveRecord) to fulfill the request. Then it returns the results (HTML or JSON) back to the user.
If you want to zoom in on Rails part we have to get a bit technical.
Actions are organized into controllers, the controllers make decisions on how to process the request & they ask the database for any data that it needs.
Then the controller renders the view.
A view is the design & content of the page.
It’s the final product that will be returned to the user.
I definitely agree with “Learn general programming concepts & the Ruby programming language first.” I actually tried learning rails first a few years ago and was so confused (and didn’t understand what was happening in my code!).
Yes! I see a lot of beginners online struggling with basic error messages & other problems that wouldn’t be an issue if they understood how Ruby works.
A good Ruby tutorial should cover these. To be more specific, I mean things like variables, loops, arrays, understanding error messages & OOP (Object-Oriented Programming).
Then for web development you also want to learn about the HTTP protocol (how websites communicate with web browsers), cookies & sessions, front-end vs back-end, etc.