[V28] Rails 3.0 porting

rebased #588.