Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does ruby on rails work?

I'm a PHP developer who knows a little bit of Ruby. I want to learn Ruby on Rails, but most of the resources I've come across treat RoR functionality as "magic" -- i.e., it has a certain internal consistency, but don't bother asking how it works in terms of Ruby, MySQL, etc.

Anyway, I want a deep understanding of how RoR works, the design decisions that went into building it, etc. In particular I'm interested in ActiveRecord, but really I'm looking for the whole package.

Any books / sites / advice welcome.

like image 893
Tom Lehman Avatar asked Oct 15 '08 00:10

Tom Lehman


People also ask

What is the point of Ruby on Rails?

Rails is a development tool which gives web developers a framework, providing structure for all the code they write. The Rails framework helps developers to build websites and applications, because it abstracts and simplifies common repetitive tasks.

Is Ruby on Rails hard to learn?

Ruby on Rails is easy to learn, if you start with the right tutorial. I'm the author of the book, Learn Ruby on Rails, which I wrote specifically for beginners (it's free, by the way, so don't earn any money by recommending it). In 2021, the Ruby language is enjoying a bit of resurgence (Ruby 3.0 is now out).

Is Ruby on Rails backend or frontend?

Ruby on Rails is used as a backend framework for web applications. It's known for efficiency and scalability. You can write rich functionality with much fewer lines of code as opposed to what you'd need in Java or Node.


2 Answers

The books "Agile Web Development with Rails" and "The Rails Way" are both pretty good. "Pro Active Record" goes really in depth for Active Record, but doesn't touch on too much else. The podcast Railscasts sometimes just uses the magic, but sometimes it explains what is really going on. Various blogs such as Art of Mission can get into what your looking for.

Additionally, using the ruby-debug gem gives you a much better understanding of what is going on - you can step into what is running behind the scenes.

like image 167
DA. Avatar answered Oct 03 '22 21:10

DA.


There are two areas here that can be examined separately:

  1. General concepts (which include design patterns, general attitude principles like DRY and CoC or even agility etc.) since they are the principles behind many design decisions in Rails. Any of these concepts can be studied independently of Rails (since they are general programming concepts). It's good to have at least some understanding of these before digging any deeper. There are many sources about such general principles all over the net (aforementioned Martin Fowler's site is one of the better sources for grasping such concepts).

  2. The way Rails implements these concepts into its corpus. There are, again, two things to have in mind here. Since Rails heavily exploits features of its mother language, it's crucial to understand Ruby's peculiarities (such as mixins and plenty of Ruby's dynamic features). The last thing to understand is how Rails uses these features, ie. how it's broken down into classes and modules, how many of its features are dynamically created on the run and so on. For this purpose, I highly recommend book Ruby for Rails from David A. Black (which is exactly about Ruby, its peculiarities and the way Rails uses them). While this book might be a bit out of date, I think it's still invaluable in its content.

like image 23
Milan Novota Avatar answered Oct 03 '22 19:10

Milan Novota