Rails 4 fixes

Made changes to support Rails 4.