SyntaxFix
Write A Post
Hire A Developer
Questions
Add this to your model:
def self.update_or_create_by(args, attributes) obj = self.find_or_create_by(args) obj.update(attributes) return obj end
With that, you can:
User.update_or_create_by({name: 'Joe'}, attributes)