Updated to work with more recent libs (Rails 4)