{"id":1558,"date":"2010-12-13T16:37:25","date_gmt":"2010-12-13T18:37:25","guid":{"rendered":"http:\/\/blog.plataformatec.com.br\/?p=1558"},"modified":"2012-10-29T18:59:48","modified_gmt":"2012-10-29T20:59:48","slug":"crafting-rails-applications-why-i-wrote-this-book","status":"publish","type":"post","link":"https:\/\/blog.plataformatec.com.br\/2010\/12\/crafting-rails-applications-why-i-wrote-this-book\/","title":{"rendered":"Crafting Rails Applications: Why I wrote this book"},"content":{"rendered":"

When I first\u00a0got\u00a0into Ruby and Rails development, I was impressed about how everything worked. A few lines of code and so much got done.\u00a0At that time, if I was reading a book or blog post that said: “just do X and Y will automagically work”. I would gladly accept those instructions.<\/p>\n

However, after a while, I wanted to understand how it really worked from the inside, so I started reading the source code from different plugins, including Rails itself. Accusing magic to be the reason for that 200 lines of code to “just work” didn’t feel right anymore.<\/p>\n

Turns out, I was not the only one with this feeling. I have been into a few big conferences this year and asked people outside the Rails community what they think about it. And, for my surprise, some of them\u00a0mentioned that “there is too much magic going on”.<\/p>\n

We have been victims of myths before, as the famous “Rails can’t scale” one, and we strongly fought back. But what about the “there is too much magic going on”? Is it myth? Who is there to blame?<\/p>\n

Yes, it is a myth and we (the Rails community) are the ones to blame for spreading it.<\/p>\n

I have already seen people explaining how “has_many :comments” works as magic: “it magically guesses the columns from your database”. Well, a more appropriate description for that would be “Convention over Configuration”. Rails uses a set of conventions so it can properly build your associations without you having to specify all tables and columns.<\/p>\n

Heck, I also did my part in the past. There was a time that\u00a0Inherited Resources’ README<\/a> was filled by words like “magic” and\u00a0 “automagically”. Just recently, I replaced all this occurencies with more detailed explanations of how it really works.<\/p>\n

The question is: isn’t it about time for us to start fighting against the “magic” myth?<\/p>\n

When I improved\u00a0Inherited Resources’ README<\/a>, the benefits were clear in my head. People using Inherited Resources would write better code and be more productive because they understood it better. And, as consequence, they would be able to troubleshoot issues easily or even contribute back. This is clearly a win-win situation.<\/p>\n

At the beginning of this year (or more specifically February, 2010) I started to put a lot of effort in writing and understanding Rails 3 architecture. Or as some people would (wrongly) say: I started to unveil the magic. After some time, it was clear that I could write better and faster code and that a lot of people could benefit from this knowledge as well.<\/p>\n

Now, 10 months later, I am happy to say that the beta version of my book\u00a0Crafting Rails Applications<\/a> is out to spread what I have learned about Rails and its applications. Rails is a framework that allows us to write web applications and an advanced Rails book should consequently be about\u00a0crafting<\/strong> them.<\/p>\n


\n\"Crafting<\/a><\/p>\n

Crafting Rails Applications<\/a> guides you through seven different tutorials, each of them using test-driven development to build a new Rails extension or application that solves common problems through the new Rails 3 APIs. You will understand how the Rails rendering stack works and customize it to read templates from the database while you learn how to mimic Active Record behavior, like validations, in any other object. You will find out how to write faster, leaner controllers, and you\u2019ll learn how to mix Sinatra applications into your Rails apps, so you can choose the most appropriate tool for the job. In addition, you will improve your productivity by customizing generators and responders.<\/p>\n

From the book cover:<\/p>\n

Rails 3 is a huge step forward. You can now easily extend the framework, change its behavior, and replace whole components to bend it to your will, all without messy hacks. This pioneering book is the first resource that deep dives into the new Rails 3 APIs and shows you how use them to write better web applications and make your day-to-day work with Rails more productive.<\/p><\/blockquote>\n

My goal is that Crafting Rails Applications<\/a> increases the Rails community thirst for knowledge, that “magic” is no longer enough to describe any part of Rails or its ecosystem.<\/p>\n

The benefits are clear: leaner code, faster applications and a well-grounded Rails community.\u00a0Check what people are saying<\/a> or get a copy on Pragmatic Programmers web site<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

When I first\u00a0got\u00a0into Ruby and Rails development, I was impressed about how everything worked. A few lines of code and so much got done.\u00a0At that time, if I was reading a book or blog post that said: “just do X and Y will automagically work”. I would gladly accept those instructions. However, after a while, … \u00bb<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[126],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/1558"}],"collection":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/comments?post=1558"}],"version-history":[{"count":13,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/1558\/revisions"}],"predecessor-version":[{"id":3163,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/posts\/1558\/revisions\/3163"}],"wp:attachment":[{"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/media?parent=1558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/categories?post=1558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.plataformatec.com.br\/wp-json\/wp\/v2\/tags?post=1558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}