# Is there an activerecord method like "FIND EXISTING OR CREATE NEW IF NONE FOUND"?

**URL:** <https://www.ruby-forum.com/t/is-there-an-activerecord-method-like-find-existing-or-create-new-if-none-found/156172>\
**Category:** Rails\
**Created:** [December 22, 2008, 4:39am UTC](https://www.ruby-forum.com/t/is-there-an-activerecord-method-like-find-existing-or-create-new-if-none-found/156172 "2008-12-22T04:39:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 22, 2008, 4:39am UTC](https://www.ruby-forum.com/t/is-there-an-activerecord-method-like-find-existing-or-create-new-if-none-found/156172/1 "2008-12-22T04:39:56Z")

</div>

Just wondering if rails has a method to look for an existing record and  
return it, but if it’s not existing then create a new record. (i.e.  
“FIND  
EXISTING OR CREATE NEW IF NONE FOUND”?)

Then when finished updating one could use the existing “save” method  
which  
caters for either a new or updated record already

Thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 22, 2008, 4:52am UTC](https://www.ruby-forum.com/t/is-there-an-activerecord-method-like-find-existing-or-create-new-if-none-found/156172/2 "2008-12-22T04:52:12Z")

</div>

Yes, look at dynamic attribute based finders in the activercord docs.  
[ActiveRecord::Base](http://api.rubyonrails.org/classes/ActiveRecord/Base.html).

Chris

On Sun, Dec 21, 2008 at 7:39 PM, Greg H. \<

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 22, 2008, 5:20am UTC](https://www.ruby-forum.com/t/is-there-an-activerecord-method-like-find-existing-or-create-new-if-none-found/156172/3 "2008-12-22T05:20:52Z")

</div>

arr thanks - I thought I’d seen them somewhere - I’d been looking  
through  
the method names (c.f. content of the doc)
