I need a method, I call it "get_or_create(item_name)". When an
Model.get_or_create(item_name) is called,
will be performed fist, if there is an item with the name, the item is
return, or a new item with the name will be created and returned.
Because most of the ActiveRecord models will need this method, I try
extend it into ActiveRecord, and put the codes into
/lib/get_or_create.rb, and require it from environment.rb.
Only one problem left... Can anyone tell me how to write the
You mean like the find_or_create_by_ dynamic finders that ActiveRecord