Ruby For Rails
Simon P. Chappell writes "This may not be the book that you think it is, if you don't read the title carefully, but it is the book you need, if you are developing applications for Ruby On Rails (often known as just Rails, or RoR, to its friends). When learning any new development platform, there are many idioms and approaches, best practices if you will, that can benefit your development efforts. This book sets out to bring you that understanding of the best way to write the Ruby side of your Rails application." Read the rest of Simon's review.
Ruby For Rails
author
David A. Black
pages
493 (17 page index)
publisher
Manning
rating
10/10
reviewer
Simon P. Chappell
ISBN
1932394699
summary
A stunningly well written explanation of real-world Ruby skills for Rails development.
I see two main audiences for this book. The first group would be those who are learning to develop Rails applications and need some help with their Ruby skills. The second group would be those who already have good Ruby chops, but who want to learn the primary Rails idioms and techniques. Naturally, there is always the curious geek crowd who might find the twofer of an introduction to writing real-world Ruby and a hype-free description of what Rails actually brings to web development, to be quite attractive. I place myself firmly in the third group, but after reading this book, I'm ready to move to the first group.
To quote it's own website, "Rails is a full-stack framework for developing database-backed web applications according to the Model-View-Control pattern." The first thing this tells us is that like any framework worth it's salt, it is fully buzzword compliant. The second thing it tells us is that it really does try to help with every layer of your application, from providing a full controller to automatically mapping your data objects to their respective backend database tables. Oh, and with the bare minimum of configuration files to boot! For those of us who have developed web applications with Java, this is a welcome break.
The first part describes "The Ruby/Rails Landscape" and has three chapters that describe how Ruby works, how Rails works and then shows a very simple example of Ruby-enhanced Rails development.
The second part describes "Ruby Building Blocks" spanning five chapters, four through eight. This part is a very good tutorial style introduction to Ruby. Chapter four introduces objects and variables with chapter five showing how to organize those objects with the concept of classes. Chapter six introduces us to modules and program organization in general. Chapter seven talks about the default object, self, and scope. Chapter eight covers control flow techniques. This is more than just a fancy way of saying conditionals and loops, because it includes one of the better explanations of closures that I've read to date.
The third part describes "Built-in Classes and Modules", in chapters nine through thirteen. Chapter nine covers some of the Ruby language essentials for Ruby development in the trenches. These include useful syntactic sugar, the family of methods that change data "in place" rather than returning a modified copy, some of the tricky aspects of the Boolean objects and the proper ways to compare two objects so that you get a comparison on their contents, which is likely to be what you want, rather than their memory location. Chapter ten looks at scalar objects: strings, symbols, numbers, times and dates. Chapter eleven examines the Ruby collections: arrays and hashes and discusses when you would use each one, based on their relative strengths. Chapter twelve looks at the regular-expression facilities within Ruby and chapter thirteen wraps up our tour of Ruby with some of the dynamic aspects of the language, including the "eval" family of methods that allow a Ruby program to run arbitrary code.
The fourth and final part describes "Rails Through Ruby and Ruby Through Rails". To quote the book, the purpose of the fourth part is "helping you get more out of Rails by knowing more about Ruby." To this end the simple application created in the first part of the book is revisited and revised. Chapter fourteen starts us out with remodeling the application written back in chapter three. Chapter fifteen looks at programmatically enhancing ActiveRecord models. Chapter sixteen covers the options available for enhancing the controllers and views. Finally, the part wraps up with chapter seventeen where techniques (and much encouragement) for exploring the Rails source code are shared.
The writing is excellent and the style is very engaging. Every concept is stunning well explained. Much as I liked and enjoyed "Programming Ruby" (the "pickaxe book" to it's friends) by Thomas, Fowler and Hunt, this book takes the state of Ruby writing to a new level.
The progression of the book is very well thought out. The first part introduces us to both Ruby and Rails. You can create basic Rails applications with very little Ruby and that's exactly what this first part walks you through. Then parts two and three teach Ruby skills and idioms that are directly applicable to Rail application creation. Part four takes these new skills and shows them being applied to the second Rails application of the book. I found this to be a very good sequence for progressing through the material.
The examples in the book are excellent and many of them are geared towards Rails-style situations. This not only helps to teach Ruby skills, but also keeps the Rails context firmly front and center during the process.
The index on this book is a magnificent 17 pages. That's not something you see too often.. The art of a good index seems to be somewhat lacking these days, but this book helps to redress the balance.
If Ruby on Rails is of no interest, then this book is most likely not the one you want. Also, if you were looking for something with an exhaustive, reference-style, coverage of Ruby, perhaps you'd be better off considering something like the "Programming Ruby" book.
This is a great book, that's very easy and enjoyable to read. It's a stunningly well written explanation of real-world Ruby skills for Rails development."
You can purchase Ruby For Rails from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page
I see two main audiences for this book. The first group would be those who are learning to develop Rails applications and need some help with their Ruby skills. The second group would be those who already have good Ruby chops, but who want to learn the primary Rails idioms and techniques. Naturally, there is always the curious geek crowd who might find the twofer of an introduction to writing real-world Ruby and a hype-free description of what Rails actually brings to web development, to be quite attractive. I place myself firmly in the third group, but after reading this book, I'm ready to move to the first group.
To quote it's own website, "Rails is a full-stack framework for developing database-backed web applications according to the Model-View-Control pattern." The first thing this tells us is that like any framework worth it's salt, it is fully buzzword compliant. The second thing it tells us is that it really does try to help with every layer of your application, from providing a full controller to automatically mapping your data objects to their respective backend database tables. Oh, and with the bare minimum of configuration files to boot! For those of us who have developed web applications with Java, this is a welcome break.
The first part describes "The Ruby/Rails Landscape" and has three chapters that describe how Ruby works, how Rails works and then shows a very simple example of Ruby-enhanced Rails development.
The second part describes "Ruby Building Blocks" spanning five chapters, four through eight. This part is a very good tutorial style introduction to Ruby. Chapter four introduces objects and variables with chapter five showing how to organize those objects with the concept of classes. Chapter six introduces us to modules and program organization in general. Chapter seven talks about the default object, self, and scope. Chapter eight covers control flow techniques. This is more than just a fancy way of saying conditionals and loops, because it includes one of the better explanations of closures that I've read to date.
The third part describes "Built-in Classes and Modules", in chapters nine through thirteen. Chapter nine covers some of the Ruby language essentials for Ruby development in the trenches. These include useful syntactic sugar, the family of methods that change data "in place" rather than returning a modified copy, some of the tricky aspects of the Boolean objects and the proper ways to compare two objects so that you get a comparison on their contents, which is likely to be what you want, rather than their memory location. Chapter ten looks at scalar objects: strings, symbols, numbers, times and dates. Chapter eleven examines the Ruby collections: arrays and hashes and discusses when you would use each one, based on their relative strengths. Chapter twelve looks at the regular-expression facilities within Ruby and chapter thirteen wraps up our tour of Ruby with some of the dynamic aspects of the language, including the "eval" family of methods that allow a Ruby program to run arbitrary code.
The fourth and final part describes "Rails Through Ruby and Ruby Through Rails". To quote the book, the purpose of the fourth part is "helping you get more out of Rails by knowing more about Ruby." To this end the simple application created in the first part of the book is revisited and revised. Chapter fourteen starts us out with remodeling the application written back in chapter three. Chapter fifteen looks at programmatically enhancing ActiveRecord models. Chapter sixteen covers the options available for enhancing the controllers and views. Finally, the part wraps up with chapter seventeen where techniques (and much encouragement) for exploring the Rails source code are shared.
The writing is excellent and the style is very engaging. Every concept is stunning well explained. Much as I liked and enjoyed "Programming Ruby" (the "pickaxe book" to it's friends) by Thomas, Fowler and Hunt, this book takes the state of Ruby writing to a new level.
The progression of the book is very well thought out. The first part introduces us to both Ruby and Rails. You can create basic Rails applications with very little Ruby and that's exactly what this first part walks you through. Then parts two and three teach Ruby skills and idioms that are directly applicable to Rail application creation. Part four takes these new skills and shows them being applied to the second Rails application of the book. I found this to be a very good sequence for progressing through the material.
The examples in the book are excellent and many of them are geared towards Rails-style situations. This not only helps to teach Ruby skills, but also keeps the Rails context firmly front and center during the process.
The index on this book is a magnificent 17 pages. That's not something you see too often.. The art of a good index seems to be somewhat lacking these days, but this book helps to redress the balance.
If Ruby on Rails is of no interest, then this book is most likely not the one you want. Also, if you were looking for something with an exhaustive, reference-style, coverage of Ruby, perhaps you'd be better off considering something like the "Programming Ruby" book.
This is a great book, that's very easy and enjoyable to read. It's a stunningly well written explanation of real-world Ruby skills for Rails development."
You can purchase Ruby For Rails from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page
I have trouble learning about things when I do not understand how they work. What I like about this book is that it goes out of its way to explain how the technology works. So many programming books start with: "Now write the following code snippit in the IDE and compile." For the first time reading a /. book review, I actually want to buy this book!
Information wants a fueled airplane waiting at the hangar and no one gets hurt.
It's about the right time for a RoR book, since things have been moving so much of late, but after 1.0 (1.1) rails things should be 'solid' enough to learn from. I used a few RoR apps for a time, but their instablitiy (which may had been caused my my inexperience) was unforgiveable. Perhaps this book would be a good read.
fak3r.com
I can't wait for the day ruby on rails loses it's buz and the infinite amount of Ruby on Rails has been derailed jokes.
I can't wait for the day all dumbasses learn the difference between its and it's
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
I would invest time and money in Ruby on Rails, except that it is obviously a passing fad. This is because Rails is designed to solve a specific problem (serving web pages), and we know for sure that the serving web pages won't be a problem for all time. What people want the web to do, and how we share information over the internet, is bound to change, and when it does the Rails way of doing things will be about as useful as the Java Applet way of doing things (which was for a time The Big Thing, but now is used only in special situations). Ruby as a whole however is definitely worth learning, since it is an adaptable language, although I fear its association with Rails may kill it when Rails dies.
Philosophy.
My boss is a buzzword-whore w/o english knowledge... and I can really imagine him how he'll do the locomotion when he'll talk BS about "Ruby for Rails" because he has seen it on top of some important-could-be Slashdot article...
I work in hell!!!
i went to purchase a rails book the other day and gave this book and the book "Agile Web Developent with Rais" and found the agile development book to be better, imho. and $10 cheaper.
Every time I see the name "Ruby on Rails" it reminds me of this coke-whore who lived in my college dorm...
I have something in common with Stephen Hawking...
Then I decided to put together a blog that worked a little differently... and realized that to do so, I needed to spend a few months learning Ruby. not woot.
Maybe I didn't stick with it long enough, but it just seems like another micromanaging "framework" to me.
My turnips listen for the soft cry of your love
Guido van Rossum was heard exclaiming that he was developing with SNAKES on a PLANE.
I can't wait for the day ruby on rails loses it's buz and the infinite amount of Ruby on Rails has been derailed jokes.
That's scheduled to occur in conjunction with Web 3.0. Ruby on Rails will be replaced with Pascalian Patterns a dynmaic, distributed, easy-to-use, personal lanuage based on Pascal.
What that video reminds me of is e.g. a demoing a word processor or other document generator. Look, you open this template, fill out the fields in this wizard, and you've got a pretty, laid-out invoce you can print and send!
Great unless your business is unusual in some way they hadn't predicted -- that is to say if your business has a significant, novel differentiation that sets you apart from all other business. That is to say: if your business is sound.
I have no problem learning a programming language, but "frameworks" just send up a red flag for me. I'm sure there are great ones...
My turnips listen for the soft cry of your love
Comment removed based on user account deletion
yay, cute lil' ponies!!
The author of this book will be teaching a class on Ruby/Ruby on Rails at Big Nerd Ranch, Aug 14 - 18:
http://www.bignerdranch.com/classes/ruby.shtml
Disclaimer - I work for Big Nerd Ranch, but I really do think the class is going to be great.
Save yourself $7.64 by buying the book here: Ruby For Rails. And if you use the "secret" A9.com discount, you can save an extra 1.57%! That's a total savings of $8.08, or 22.82%!
You should give up writing. How did you graduate high school? Do you even know what a comma is? Do you know how to construct a sentence? Reading your review makes everyone dumber.
http://sqlonrails.org/
mt
Quit the hype allready. There are at least 3 oss web packages out there that are better in more than just a few aspects:
django ( http://www.djangoproject.com/ )
Symfony ( http://www.symfony-project.com/ )
Zope ( http://www.zope.org/ )
Zope is by far the oldest and most sophisticated. Django is Rails done right and in Python and Symfony is a PHP metaframework that includes Propel and some other third party goodies with tons of very neat PHP 5 foundation work. Each one of these kick Rails up and down the street when it comes to ease of use, ease of deployment, available documentation and performance (Zope may be a little slower, but they have a full-blownobject relational DB built in that makes SQL look like peek and poking a c64 back in 1985).
And since the Ruby on Rails people use PHP to power their Rails website (oh, the irony; http://rubyonrails.org/index.php ) I'd trust in even PHP being able to perform more than good in the newest lineup of Frameworks.
So quit the rails-only hype allready, it's anoying.
We suffer more in our imagination than in reality. - Seneca
I've tried Rails. It's pretty good, but it needs to be more mature because it lacks support for the more advanced stuff. Among the things that it currently (seem) to lack are:
- Support for saving database records using database function. In other words, I want Rails to automatically perform a query that looks like this:
INSERT INTO foo VALUES(NOW());
I want to insert a record that uses the database server's time instead of the web server's time.
Or, something like this:
INSERT INTO foo VALUES('bar', INET_HTON('127.0.0.1')); --- notice the INET_HTON() part
In this example, I want to store IP addresses as integers in the database.
- Apache integration is still too immature. I don't know about Apache 1, but Apache 2 integration using FastCGI doesn't work *at all*. The documentation on the website about Apache integration is very messy: different pages suggest different things. After much research I found out that:
(1) mod_fastcgi (not FastCGI itself, which is something else!) is dead, use fcgid instead.
(2) Integration using fcgid doesn't work either!
After a lot more research I found a working solution: make Apache proxy requests to a lighttpd server, which is running the Rails app. This doesn't seem like an ideal situation.
- Documentation is still too immature. While the API references are pretty good, the Wiki is very messy (see Apache integration).
I recently started reading this book, the style is indeed very engaging. It may not cover as much as the pick axe book, but at least it is not a pain in the ass to read.
But see, that's a problem I've encountered recently; one of my team members for a project we're working on was all gung-ho about doing it in Rails, convinced that we could put things together as "one-liners" (his favourite word now, it seems). From the early stages, he was adamant that we do it in Rails, even though neither myself nor the third person in the group knew Ruby or Rails. So about halfway through the planning stages, I asked the guy what projects he had coded in Rails in the past.
He'd watched the screencast and done the tutorial from a Rails book. That's it.
Now, I'm not saying learning Rails (and Ruby) is a bad thing, don't get me wrong. But in early discussions of the project far before this point I'd made it clear that I had about six years of solid, real-world PHP experience and the third member had about a year.
If the project were more open-ended, we may have ended up trying to do it in Rails. However, having a deadline, we ended up deciding to do the project in CakePHP, a bit of a compromise. So far, it's worked out really well for us, and we still get the benefit of coding in a MVC RAD framework.
But yeah, I think lots of people buy into the hype of Rails too easily without thinking about it or trying anything different from the hand-held tutorials.
It's better to vote for what you want and not get it than to vote for what you don't want and get it.
- E. Debs
With these tools, I have never found any need for Ruby, with or without Rails. I tried it and the first thing I noticed was ugliest quirk they stole from FORTRAN-77: the "end" statement. All the editors I use have a syntax enhancement mode that shows which brace pairs with the one where the cursor is. Why, oh why, throw away that very useful feature? What, exactly, did the Ruby creators think they would gain with that? This very small detail shows that the whole language isn't as well thought out as its fans claim, so I guess I got prejudiced against Ruby from the very beginning. When you code for a living, when the lines of code you wrote in your decades of work start to get into the millions, you will know how these apparently small details add up in the end. I need my language to work together with my editor, not fight against it.
Ruby fans remind me of Lisp fans. Very vocal, always ready to present their arguments, concede no points, admit no failures. But one gets the impression that they are mostly academics, people who do not code for a living. If you have to solve a real life problem instead of a textbook example there are more practical languages to work with.
Oh, sure, Ruby is very flexible, very adaptable, but in professional work one needs the efficiency of specialization. I use PHP for web access to databases, Perl for small scripts that handle text files, C++ with Qt for GUI work, Python for prototypes and C for deliverable number crunching applications. For professional work one needs professional tools, swiss army knives are for boy scouts.
Rails was written by a PHPtard. That's why there is no seperation at all between controller and view, they just share all the same data. That's why everything is a function in the same namespace that_is_a_million_miles_long_for_no_reason().
My only problem with the "convention or configuration" mantra is the lack of transparency: unless you *know* that RoR does all this automagic pluralization and convention "guesswork" you're destined to bang your head off the corner of the desk trying to figure out how it works. I'm thinking in 2-3 years time and somebody needs to maintain a RoR app who might be familiar with language xyz and abc, but not Ruby. Good luck trying to step through the code and figuring out how it works without investing some serious time in understanding the language and framework intimately. No, I'm not advocating reems of XML config files ala J2EE frameworks, but I see nothing wrong with a simple conf file for most projects.
body massage!
I read this book last month. It is a _good_ book.
My only complaint is that it is very wordy. I caught myself thinking several times "Yes, I get it.. can we move on now?"
I can't wait for the day morons like you learn about ending sentences with some sort of valid punctuation.
--
WHO ATE MY BREAKFAST PANTS?
Amazon really ticks me off lately. I think they just throw out the phrase "usually ships within 24 hours" everywhere, since no one can really define what "usually" means. I just ordered "Programming Ruby" on Sunday. It's now late Wednesday night and it STILL has not shipped. I don't mind the slow Super Saver Shipping but at least get ONE BOOK out the door within a couple days... sheesh. Yeah, I'm switching to bookpool or buy.com.
Vote Libertarian
if you use python in your shop already, then use a python-based web stack.
if you use perl, use jifty
once you introduce a new langauge, you will start having to code everything twice. its not worth it.
Frankly, PHP and Java are closer by that metric. Ruby is in the company of Smalltalk. Small-fucking-talk, motherfucker.
The people I curse most, the people that I spend every waking hour condemning and conspiring to send to hell are the inventors of Java and PHP.
Seriously, who does not believe these people are Satan's evil little helpers upon the Earth?
Satanists, that's who! Satanists want nothing fucking to do with those guys. Not even fucking baby eating, pig blood drinking Satan-fucking-ists.
I usually find RoR disabled on most web servers... What's the use?
For some odd reason I feel like I'm reading a 9th grade current events summary. Hope your coding skillz are better than your grammatical skillz there Simon...sigh...
To have a right to do a thing is not at all the same as to be right in doing it
OK, I couldn't find it in Wikipedia, and I've never heard the term. What is a type 3? I learn much better when I understand why. Does that make me a type 3 or a type 4 or something?
Software sucks. Open Source sucks less.