Rails4 fixes

Here are some Rails4 fixes that seem to work for me.  Note that they're not back-compatible with Rails3 so a major version bump is probably in order.