Rails 4 fixes

This fixes a couple of issues discovered when using Rails 4.