The most important thing is to keep yourself focused. Rails is huge and complicated, you’ll always have to know what you want to do.
This is the second compilation of my general know-how following Sources to learn Rails — compiled after one year of learning.
Step 1. Careful Database Modeling
Rails is a descriptive, declarative, high level programming language. Most times you won’t need to write raw SQL procedures, instead you’ll model them with ActiveRecord.
Learning ActiveRecord by examples is crucial. You’ll have to know what are ActiveRecords’ capabilities and limitations. There are many on both sides.
Don’t stop until you’ll discover and understand has_many :through polymorphic associations, smart proxies, and the class_name = /foreign_key = magic.
Use model diagram generators to visualize your database, sooner or later you’ll learn how a healthy database looks on the diagram.
Step 2. Test your models first
Once you think you are ready with your models and relationships start using script/console to see if everything is fine. Script/console is the first and most immediate interface to your application. You can CRUD data and verify relationships, optimize your queries and even the database model. Use the log files to see the queries generated.
Step 3. Document with RSpec
RSpec for models is like collecting all your script/console tests into a Ruby program. It also helps you to refactor / DRY your model code. If you create the specs for models:
- you’ll be sure your database is working fine
- your model code will be as simple and as expressive it should be
- if you’ll later modify the database and the code RSpec will alert you if something is broken
- Bonus: You’ll get for free a complete, live documentation of your code!
Once you are sure the foundations of your app are solid like rock, and future modifications of the code will be verified in an automatic way, you can start building the presentation to impress your customers.
Step 4. Start thinking about the View
The interface is the application — says many usability experts. And all we can agree.
Sadly Rails won’t help you too much on building interfaces as easily as model relationships. ActionView is a very well equipped basic interface library, but you’ll have to work it out and extend it hard to have the best user interface.
There are many complete View utilities out there, like ActiveScaffold or Hobo just mentioning the biggest. And there are many templating systems like Markaby, Liquid etc or AJAX libraries. You’ll have to check all them out to see if they fit your needs.
However there is a big trade-off using these helper utilities: they will speed up your development but they will take away from your total freedom in creating the user interface. (Especially ActiveScaffold and Hobo, not the AJAX libraries. Templating systems are just useful as they can be with less trade-offs.)
I’m using ActiveScaffold for my UI (Hobo is not finalized yet) and I’ve realized it was maybe better to create my own library from the beginning because AS has many limitations, incompatibilities with Rails, and the documentation is shady. (The forums are very nice, they helped me out!). Sooner or later I’ll use AS only for heavy data inputs for administrators and the nice visualization, the end user experience will be made by me.
… hope to continue soon …


