SyntaxFix
Write A Post
Hire A Developer
Questions
You can do it in one statement like this:
CachedObject.where(key: "the given key").first_or_create! do |cached| cached.attribute1 = 'attribute value' cached.attribute2 = 'attribute value' end