Archive for the 'Rails' Category

Rails Validation fieldWithErrors annoyance

Thursday, July 3rd, 2008

So I’m thoroughly annoyed that a fieldWithErrors div wraps around a field that fails validation. I added a file called field_with_error_fix.rb in config/initializers to solve this pesky problem. It has the following code:

ActionView::Base.field_error_proc = Proc.new { |html_tag, instance|
"<span class=\"fieldWithErrors\">#{html_tag}</span>" }

Goodbye inappropriate divs!

What’s New In Rails 2.1 - A Great Reference

Monday, June 23rd, 2008

I found this today - kudos to Carlos Brando for putting together an awesome reference! It’s a summary of all the new features rolled into Ruby on Rails 2.1.

Ruby on Rails 2.1 - What’s New

RailsConf Day 2 Wrap-Up

Monday, June 2nd, 2008

What a cool day. Here’s a quick summary of everything I attend:

  • Jeremy Kemper’s keynote - Rails 2.1 is getting released! Awesome changes to migrations (no more migration number collisions), timezone support, tighter integration with memcache. Coolest of all and something that always bugged me in ActiveRecord - being able to check is an ActiveRecord object was actually modified. The introduction of the changed? method should be very handy.
  • Mingle - I love Mingle. I checked out this talk because I wanted to learn how to really use Card trees and aggregate properties (some new features in Mingle 2.0). I ended up finding out some really cool functionality that I didn’t know existed (read: project variables). After every iteration rolls by, I previously had to go in and change all the views to reflect the change in iterations. Now, I can do it in one place with project variables. Rock!
  • Advanced Restful Rails - I thought this talk was pretty cool. He addressed a lot of patterns that do not fit in the stereotypical resource generator. I really dug the overall message - there’s really 2 steps to making a good restful architecture. It’s really that simple, and it’s not far off from good Object Oriented design.

    1. Identify your resource
    2. Expose the methods you want to
  • Fast, Sexy, and Svelte: Our Kind of Rails Testing - this was a good talk. Mainly impressed with DeepTest - it runs your RSPECS in parallel rather than sequentially. For acceptance testing, the recommended Selenium, but I actually prefer SpiderTest. It’s not so dependent on markup and is done in memory rather than in browser

  • Integration Testing With RSpec’s Story Runner - yet another great talk on testing. I’m still not sold on stories as part of the RSpec framework, but I’m at least willing to give it another try after David’s great walkthrough
  • The Great Test Framework Dance-Off - Josh gets my talk of the day award. This was a totally unbiased look at three popular frameworks RSpec, Test::Unit, and Thoughtbot’s Shoulda
  • The Great Kent Beck - I have to be honest, I didn’t get a lot out of Kent’s talk. It was cool to reminisce about TDD, but I didn’t get inspired. Honestly, Q&A was the best part of the keynote.

Rails Routing Silliness

Saturday, April 26th, 2008
  map.resources :organizations do |organization|
    organization.resources :members, :member => {:activate => :get}
  end
  
  map.resources :organizations,
    :has_many => :members

There’s a lot of debate going on around these two blocks of code. Why am I opting for the top instead of the bottom? Because there’s no documentation for the bottom! I have no idea how to add a custom, member action to the has_many style of routing.

One thing is starting to annoy me about the latest revisions to Rails. Rails developers are very opinionated and want you as a fellow developer to follow recent conventions, but how can I follow a convention if there’s no documentation to support it?

Of course, I can’t really complain because I haven’t contributed to the documentation. My point is that if DHH and the rest of the core team have strong opinions about recent changes, they should put more of an emphasis on revising documentation to get people using the right conventions.

Railscasts - Get Your Weekly Dose of Ruby on Rails

Wednesday, June 27th, 2007

There are many great sites that publish educational material for the Ruby on Rails framework. Of note, Ryan Bates does a great job with Railscasts. I think screencasts are a great way to learn proper programming practices. Block off some time every week to review this site. I’ve already found it immensely helpful.

Here are some of my favorites: