updated for Rails 3/4