Hi,
I'm not exactly sure what you're asking about, but if you want to find
out if the result was already in the db or was it just created, you
could use find_or_initialize_by instead:
post = Post.find_or_initialize_by_title("something completely
different")
post.new_record? # false if it was found in the db, true otherwise
post.save if post.new_record? # this way you can save it only if it's
not already in the db
On 25 Lut, 20:35, Phlip <[email protected]> wrote:
> Jo Jo wrote:
> > If I use find_or_create_by_.. is it possible to define at was it created
> > or founded?
>
> Could you ask the question a different way?
>
> Are you trying to do this (WARNING: made up!)...
>
> find_or_create( my_by_var, 42 )
>
> ...such that you can vary my_by_var, and create by different things?
>
> I will now use Google Codesearch to find the missing_method which wraps that
> (that's a tip in itself!), because I myself am hankering for an
> update_or_create_by...
>
> --
> Phlip
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---