There is. For new record (creation, assignment and saving to db in one go):
record = Metric.create(hash)
Creation and assignment without saving:
record = Metric.new(hash)
For existing record, assigning and saving:
record.update_attributes(hash)
and assignnment without saving:
record.assign_attributes(hash)
Note:
Saving methods (create
and update
) will not raise an exception if saving fails (e.g because of failing validation). Saving fails quietly. If you want to get an exception when this happens, use banged versions: create!
and update_attributes!