Updated for Rails 4