How to take a hash of key/val pairs and set ActiveRecord attributes with it

Viewed 4179

I have a Ruby hash that I'm retrieving via a remote web API. I have an ActiveRecord model that has the same attributes as the keys in the hash. Is there a trivial way with Ruby on Rails 4 to assign the key/val pairs from the hash to the model instance? Is it possible to ignore the keys that do not exist?

2 Answers
Related