Hacker News new | past | comments | ask | show | jobs | submit login
Cool Things in Rails 2.3 (railspikes.com)
41 points by 100k on March 30, 2009 | hide | past | favorite | 6 comments



Rails has really kept up its development pace nicely. Nested assignments and forms are a wonderful addition. Dealing with related data (in forms and saving) had always been quite a pain and they've done a great job of making that a lot easier.

Some things not mentioned in the slideshow that were important (at least in my opinion):

* Dynamic scopes: you can say Article.scope_by_XXX and it will allow you to use scopes without explicitly naming all of them.

* Batch processing: this allows you to get the results of a query in smaller batches so that you don't have to load everything into memory at once.

* Rack support: it's nice to have Rails being able to be deployed in the way that the community is going for Ruby apps.

* Try: probably one of the best additions. It allows you to say @person.spouse.try(:first_name). Normally, if the person didn't have a spouse and you did @person.spouse.first_name you'd get an exception saying that nil (which is what @person.spouse would evaluate to) doesn't have a method first_name - which is true. This way you don't have to keep saying, "only call @person.spouse.first_name if the @person has a spouse".

* Application Templates: These are basically shortcut files you can make for setting up a new project. We all have slight variants and we can set up the default things we want in all our applications so we aren't starting from such a blank slate (and that way you don't forget to do things like create a .gitignore file before you put your database password out there for the world to see).


Nested forms scratches the worst itch for me. Compared to the other changes it's nothing huge, but it sure makes day-to-day coding more developer friendly. That's what RoR is about anyway.


Good list of other cool things. (Rack is sort of implicitly in my presentation due to the Rails Metal thing.)

I had to really narrow it down to get 10 things.

I wanted to put ActiveSupport::MessageEncryptor in there for sure but I couldn't figure out anything else to take out so I had to cut it.


Oh, good to hear about try() -- that totally beats Object#andand.


Hmm.. not really. But its ok. andand is much cooler since you can call functions directly, and with arguments. Try is good for sending simple messages like :size and :errors and not have to care if the object is nil


#9 is especially important. The parameter parsing code in Rails < 2.3 was painful to work with for all but the most rudimentary forms. Great to finally see it in there!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: