Another week, another update on Edge Rails. And man, you aren’t making this easy on me, are ya? This weekend, in case you hadn’t already heard, was the first Rails and RailsBridge BugMash. If my count is correct, there were roughly 300 commits to the Rails master over the past six days, with most of them pushing in over the weekend. Talk about a trial by fire! There’s a lot of really good stuff in here, so let’s get started:
ActiveRecord (or probably more accurately, ActiveModel) received a lot of validation love this weekend.
validates_length_of
. So, validates_length_of :name, :within => (5...10)
will actually restrict the valid length to between 5 and 9.validates_length_of :name, :maximum => 10
will now allow nil
values to validate, by default.validates_format_of
if you can’t validates_format_of :without => /.../
? Well, not much, let me tell you… Elliot Winkler provided a patch do to just that.validates_with
. This little beauty now allows you place validation code into an external class. And that, my friends, means better encapsulation of responsibility, I’ll bet on better readability, and even shared validation logic across your application or possibly even gems. Nice job, Jeff.There were quite a number of updates to ActiveResource over the weekend. And, I’m sure many of you are going to be quite thankful for some of these:
ActiveResource.exists?
got some polish from Jatinder Singh. And, by polish, I really mean that now it works. Instead of raising Net::HTTP errors.Thanks to Dan Cheail, we finally get a grouped_collection_select
helper. I mean come on, there’s no way you can tell me that you can’t love this:
class Continent < ActiveRecord::Base
class Country < ActiveRecord::Base
class City < ActiveRecord::Base
<%= grouped_collection_select(:city, :country_id, @continents, :countries, :name, :id, :name) %>
<select name="city[country_id]">
<optgroup label="Africa">
<option value="1">South Africa</option>
<option value="3">Somalia</option>
</optgroup>
<optgroup label="Europe">
<option value="7" selected="selected">Denmark</option>
<option value="2">Ireland</option>
</optgroup>
</select>
This weekend brought a small, but incredibly useful patch to rake routes
by Mike Breen. Now you can filter the listed results by passing in CONTROLLER=foo
. That’s. just. awesome. Personally, it’s gotten to the point that my fingers just assume that they are to append the “| grep foo
” portion whenever I type rake routes
.. apparently I have nerd muscle memory. *sigh*
I’ll end the BugMash portion here with just a few more commits worth mentioning. Certainly this wasn’t the extent of the BugMash and I could probably fill up another post just as long with even more mashed bugs and features, but it’s gotta end somewhere, right?
textilize
helper. So, now, textilize("Testing <b>HTML</b>", :filter_html)
will actually filter the HTML!redirect_to(User)
- note that User
is a class not an instance here - as a synonym for redirect_to(users_url)
. Thanks to Niklas Holmgren for that.:file
delivery method, you can even define your own custom :location
for directory storage.model.destroyed?
. This nifty method will return true
only if the instance you’re currently looking at has been successfully destroyed.Now that we’re clear of those, here are a couple of non-BugMash-related topics which were addressed:
There’s a difference between knowing the path and walking the path. And this week saw some updates to Rails, mostly around testing, adding improved Oracle database support. A large amount of this effort appears to be coming from one man, Raimonds Simanovskis. I know when we talk about databases with Rails, it’s always the big four - SQLite, MySQL, PostgreSQL, and that other one which shall not be named - so it’s nice to get a little more focus the 800lb. gorilla in the room.
This update fixed failing test cases due to offset and limits, empty strings storing as null, numeric results from ActiveRecord.sum, Oracle not utilizing an ‘AS’ keyword on joins, and many more.
José Valim and Yehuda Katz (and many others, I’m sure) have put in some excellent work in refactoring the Rails renderer. In fact, the majority of the rendering code has come to find a home in a common object, the AbstractController::Responder. Certainly, this may not be its final resting place, but it’s interesting to note that once a lot of the render logic was brought together the core team was able to quickly identify and refactor the logic to see some dramatic speed increases. At one point, Yehuda even mentioned a tested benchmark showing, “10% faster partial rendering,” than Rails 2.3.
I know that in the RailsEnvy podcast I jabbed a few ribs about the amount of time it’s taken to see a Rails 3.0 release, but it’s important to note that these guys are doing some seriously awesome work. I’m seeing extensive testing and benchmarking and very intelligent refactorings. We’ve really got some great things yet to come.
I’m sure I’ve left out several important and/or interesting commits this week. So, I apologize if one of those was yours. I, and the rest of the community, certainly appreciate the effort you all put in this weekend and Rails is certainly better for it. So, thank you, thank you, thank you to all of you BugMashers out there. And, if you missed out on getting your commit in this round, we’re certainly ready to welcome you into the next.
If you prefer to have a shorter audio summary of this content, you should check out a new podcast just launched by Envy Labs, called Ruby5; a 5 minute, twice-weekly podcast covering Ruby and Ruby on Rails news.
Photo: Brooklyn Bridge Virtual Tour by Diego_3336