You could do all of this a bit more concisely like:

```ruby
def self.for_name_and_version(name, version)
  where(name: name, version_constraint: version).first_or_create!
end
```