I need a method, I call it “get_or_create(item_name)”. When an
Model.get_or_create(item_name) is called, Model.find_by_name(item_name)
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 to
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