Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting started with learning the Rails source [closed]

I've been using Ruby on Rails for many projects lately, and I thought it would be interesting to take a look at the Rails source and really see how things operate underneath. I think it'd be a great learning experience and would probably enhance the way I code Rails apps all the more.

Does anyone have any tips on how to get started? And where within the Rails source does an application begin to be executed? Perhaps if I started there, I could see how everything is loaded and works in general.

like image 541
joeellis Avatar asked Apr 22 '10 03:04

joeellis


People also ask

Is Ruby on Rails still relevant 2022?

As of 2022, both Ruby and Rails are still relevant in software engineering, powering thousands of websites.

Is Rails hard to learn?

Learning Rails is hard because there are many independent concepts to learn. If you are not already a web developer (competent with the branches to the left), then the prospect of learning a variety of concepts to do the simplest things in Rails can be daunting.

Can a beginner learn Ruby on Rails?

Ruby on Rails is beginner-friendly Here are just a few examples of why Ruby on Rails is a good programming language for you to start with : Unlike Javascript and many other languages, you don't need to remember to end your lines with a semicolon (;)

Do I need to learn Ruby before Rails?

Ruby on Rails is written in the Ruby programming language. If you're new to Ruby, you'll need to take Ruby language courses before Rails courses, because otherwise at the next stages, when you face more serious issues, you'll struggle with the Ruby code.


2 Answers

I think it'd be a great learning experience and would probably enhance the way I code Rails apps all the more.

This is a great idea!

The first place you should start from is the Rails source on GitHub (here the branch 2.3). If you are using Rails, you are probably familiar with the fact that Rails itself is composed by a few different Gems: ActiveRecord, ActiveSupport, ...

Jumping immediately into the code cannot be that simple. I would suggest you two alternative ways to start digging into Rails codebase:

  • take the habit, any time you use a method, an helper or a Rails command to jump to lookup the method in the source code and read it. Try to understand its context, how it works and which methods/libraries it uses. Then, each time the method A uses a method B, start to walk back and lookup method B. Set a limit to the number of reverse lookup, for example 2 upper levels so that you won't end up looking up the entire framework starting from the link_to helper.

  • instead of starting from the top of the repository, choose the library you are most familiar with. If you don't have any preference, start from ActiveSupport. ActiveSupport is the Rails toolkit. It provides tons of extensions you can use in your Rails code and even in your Ruby programs.

It will take a while before you'll be able to put together all the information and understand how a single Rails application works, but it is definitely worth the effort.

As a side note, a few month ago I started a series called Inside Ruby on Rails. You might want to give it a look.

like image 135
Simone Carletti Avatar answered Oct 12 '22 13:10

Simone Carletti


There is a guide about the Rails (3.0) initialization process: http://ryanbigg.com/guides/initialization.html

like image 26
dhofstet Avatar answered Oct 12 '22 12:10

dhofstet