
Since its release, the third version of this wonderful framework has begun to actively push the second one. This, of course, is fine, but there are quite a few changes between versions, some have the status of deprecated. And this means that knowledge of the second version alone will not be enough to fully use Rails.
That is how I argued when I began to search for literature on third rails. Why just literature, not documentation? Because only in the fall I paid attention to this framework, but learning is still better from books (I think so). And what was my joy when I came across the site of the book
Beginning Rails 3 , which was published only in September.
Book format
Just want to note that this book is initially an e-book, thanks to which it is quite comfortable to read from a monitor or an e-book. Of course, the print version is also sold, but it seems to me that it is better (and cheaper, and more reliable with our mail) to buy an electronic version, and then, if necessary, to print it yourself.
The book, unfortunately, was not translated into Russian, but was written in a very accessible language and read without problems.
Material feed
The authors pay a lot of attention not only to the description of the framework itself, but also to its philosophy. Before describing the use of any element of the platform, they smoothly lead the reader to the problem that this element is intended to solve (for example, the problem of maintaining the relevance of the database structure when using SLE before the chapter on migrations) and try to explain why the Rails developers chose this path solutions.
The book is built on the development of the blog. Starting with the simplest CRUD operations and a scaffolder, by the end of the book we come to the issues of testing, internationalization and application deployment.
Finished examples are accompanied by a link to github, where you can download the source. In the listings themselves, if the code from the old examples is modified, the changes made are highlighted in bold, which greatly simplifies the analysis of the code. There are enough comments in the code, plus each action is then signed by the authors in sufficient detail so that the examples have no questions. Important points are highlighted in notes and warnings that you will not accidentally rush through.
')
Content
As I said, the book is built on the gradual creation of a blog. Each chapter describes a specific element of the framework, and in parallel with the description of the element, we are immediately shown how to use it in a real application, and not on synthetic examples.
But I would like to say about each chapter separately.
Chapter 1. Introducing the Rails Framework
In this chapter, starting from the reasons why frameworks appear in general, the authors move on to the reasons why you should stop choosing Rails and give arguments such arguments as the convenience of Ruby itself (metaprogramming, DSL, convenient syntax, object-orientation; two points can be brought under any other languages, but as it is written), the proximity of the framework to the principles of agile development, the concept of “configuration primacy”, KISS and DRY, the convenience of “syntax sugar”.
Further, the MVC pattern, the modularity of the framework and, remarkably, still pay attention to the fact that Rails is “not a silver bullet”.
In general, the chapter gives a good idea of ​​why we need rails and frameworks in general, as well as what ideas are used in developing Rails applications.
Chapter 2. Getting Started
In the second chapter, everything is standard for such books. Installing Rails on Mac, Linux and Windows, installing SQLite, creating the first project (well, who would doubt that it will be “Hello, world!”) And launching the web server built into the rails.
Chapter 3. Getting Something Running
And here begins the creation of the very blog. The chapter is a “quick start” for creating an application.
As well as in the previous chapter creation of the project is considered. But now describes the purpose of each directory, the creation of a database. Various generators, migrations, and scaffolders are briefly discussed.
By the end of the chapter, we will get a fully functional single-user CRUD blog.
Chapter 4. Working with a Database: Active Record
It all starts with an understanding of the essence of ORM and ActiveRecord in particular. It is explained that relational and object approaches are completely different things and that ORM is called to “build a bridge” between them.
Next is the work with the console rails, which in the course of the book is used quite often.
Well, the main material of the chapter is a detailed description of what CRUD is and a fairly detailed description of these methods in Rails.
Of course, not all parameters of all methods are described, but what is said is quite enough, so that you do not get lost in the documentation.
Chapter 5. Advanced Active Record: Enhancing Your Models
In this chapter, the model is considered more deeply. Topics such as the expansion of the model with its methods in addition to CRUD, associations (very detailed), advanced search (conditions, sets), validators (and here everything is rather poor, no documentation can be done), callbacks and models and putting them into separate files (observers)
Each topic runs in parallel with the blog's functionality. The benefits of this become apparent when it comes to associations. Really in detail all options of associations are signed.
Chapter 6. Action Pack: Working with the Controller
This chapter lives up to its title. It covers the entire path of the request, starting from the router and ending with the render. The RESTful approach is considered in great detail, not only “here you’ll get the scaffolder routes, controller and templates,” but also a detailed description of how this is generated and how to do it all yourself.
Chapter 7: Advanced Action Pack
Continuation of the sixth chapter. The most important part of this chapter is sessions. This topic logically ends with the creation of a user authorization mechanism on the blog site. Also here we learn about the nested resources and their routing, filters and controllers helper. And all this, of course, is accompanied by a gradual improvement in the blog.
Chapter 8: Improving Interaction with Ajax
With this chapter, I had the most questions. Installing jQuery is considered, but not a word about plugins that simplify this process describes the manual replacement of libraries and editing the config. If I'm not mistaken, there are ready-made solutions that solve this issue.
Also there is no word about RJS-templates. The examples use pure javascript with <% ...%> inserts. I still do not know the rails so well, but the RJS from the third version did not seem to be removed. And in general, the chapter is very scanty, and after reading it, there remains the feeling that AJAX in Rails is not very well developed.
Chapter 9: Sending and Receiving E-Mail
The focus here is on sending emails. Both simple text letters and more complex ones, including HTML and attachments, are considered.
Also, the beginning of the chapter discusses the configuration of the environment for working with the mail server, and at the end a couple of words about receiving letters.
Chapter 10: Testing Your Application
In my opinion, this is one of the most interesting chapters of the book. Unit tests, and then functional and integration tests, are considered very clearly and in detail. It becomes clear why you need to write tests, what tests for which parts of the application to use. Of course, the method of writing good tests is not fully described here, but the basis for further development in this direction is given a good one. The testing mechanisms that are built into Rails are described in sufficient detail. All material is considered to create a set of tests for the blog with which we work throughout the book.
Chapter 11: Internationalization
In this chapter, we will first be introduced to the concepts of internationalization and localization, after which we will describe Rails tools for building multilingual applications. Everything is simple, clear and with examples.
Chapter 12: Extending Rails with Plug-ins
Also a very useful chapter. First, we consider the use of plugins in general using the example of the act_as_tagged plugin, and then we are shown how to create your own plugin using a simple example. At the end of the chapter, the authors once again remind you that you only need to write your plugins if the plug-in with the necessary functionality has not yet been written.
Chapter 13: Deploying Your Rails Applications
Here we will briefly talk about the benefits of deploying the application on a hosting using Capistrano and give links to several hosting sites where you can place your Rails application.
Everything is given very briefly, rather for informational purposes than reference ones.
Applications
At the end of the book are given several applications on Ruby, SQL, community and Git. With the exception of the community, semantic load applications are practically not carried.
Total
In general, the book is of sufficiently high quality and is aimed at those who are just introduced to Rails. Experienced rails are unlikely to find something particularly useful on its pages, but perhaps some separate chapters will help them.
On the desktop, this book does not pull, but if you are just starting to get acquainted with Rails, then this book will undoubtedly help you join the ranks of the railmen.