3

I have been making websites in PHP and MySQL for almost ten years now but I have never used a framework. This means I have hand coded everything and I know how the code all works and interacts with itself.

Wanting to expand my horizons I have picked up Ruby on Rails to learn another web language, framework, DB etc. I have been following the Ruby on Rails tutorial and it is going smoothly so far but what bugs me how much of a black box it feels. there's too much magic, and stuff happens just because it does. Example of this "magic" include, if I add to the routes file "resources :users" all of a sudden I have near infinite possible links like /new /user/1 /user/1/edit etc. Or if I want to add a column to my db table I have to do something like this in the console "rails integrate _to_table value:type" and then I have to "rake" the db.

I have been able to make stuff following the tutorial but I don't understand what I am doing. I know part of it will come through experience but I want to know how and why Rails is doing what it does.

What are some good resources, online and books, where I can learn how RoR works?

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Reily Bourne
  • 5,117
  • 9
  • 30
  • 41
  • 2
    convention over configuration rules there – apneadiving Mar 08 '12 at 14:46
  • Ruby the language might seem magical too because of its flexibility, so the Ruby-on-Rails magic somewhat stems from the magic of Ruby. Learning (really) ruby will make you understand RoR (or other Ruby frameworks) better. – Valentin V Mar 08 '12 at 15:06
  • See also this question on [Rails conventions](http://stackoverflow.com/questions/3554054/what-are-all-the-conventions-for-ruby-on-rails) – GuruM Apr 06 '14 at 06:03
  • Many of the "magic"/conventions arise by using Ruby Meta-programming features you might find Pragmatic Programmers book "Meta-programming Ruby - Program like the Ruby Pros" useful. – GuruM Apr 06 '14 at 06:34

4 Answers4

5

Yes, it takes a while to know what all the magic is, but you'll get there eventually if you stick with it.

The 'bible' for ruby on rails development is http://pragprog.com/book/rails4/agile-web-development-with-rails

The 'bible' for the ruby language itself is the 'pickaxe' book, with contributions from the ruby language author himself. http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177

Ryan Bates has done HUNDREDS of free sceencasts and he is famous for having a really great approach, using the framework effectively. Every good rubiest rate these highly. http://railscasts.com/

Many folks find the "zombies" courses really good. http://railsforzombies.org/

Finally I'll offer my own bookmarks site with over 50 sites for rails:
http://www.rormd.com/linker/groups/1

and 20+ sites for ruby at
http://www.rormd.com/linker/groups/4

While you are learning a good IDE can help a lot. I used eclipse, then netbeans then rubyMine (from our friend at IntelliJ, well known for their java editor. rubyMine has the most features. It is not free but for the price (somewhere in the $24-$75 range, depending on special offers) it's well worth the cost.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
3

This is for newcomers if they wants to learn ruby on rails, even don't know Ruby. I can say try this first and jump on others book.

Just hit on below link and see there are two tutorials available for Ruby on Rails 3.0 and 3.2

Ruby on Rails Tutorials link for Rails 3.0 and 3.2

for those tutorials you do not required Ruby backgrounds

even I like Head First Rails, this book is also good for understand - just rails (no TDB), so initial you can set in rails environment and after that jump on above tutorial link

AMIC MING
  • 6,306
  • 6
  • 46
  • 62
2

You can see the entire code on Github http://github.com/rails/rails.

The Jose Valim Book Crafting rails application help to understand a lot of internal in rails too

shingara
  • 46,608
  • 11
  • 99
  • 105
1

I would say that using the terms "black-box" and "magic" is a quite inadequate and maybe even a bit depreciative. I believe that the difference you are feeling comes from the fact that Ruby is a very different language than PHP, and that it is easier to code high-level abstractions and conventions in Ruby that in PHP. Rails is full of these abstractions and conventions, and these may be quite confusing, specially if you have no ideia of how they internaly work.

Maybe it's not about Rails that you should be reading. I'd say that you should try to understand Ruby in the first place. A good understanding of its blocks, its object model, and its mixins is mandatory in order make that "black-box" feeling go away.

Programming in a modern programming language ain't black magic. Debugging Fortran code by printing the code and using crystals over the papersheets to find the bugs was.

Pedro Rolo
  • 28,273
  • 12
  • 60
  • 94