[V2] Rails 3.0 porting

New version of #295.