search for: find_for_create_modify

Displaying 1 result from an estimated 1 matches for "find_for_create_modify".

2006 May 27
2
ActiveRecord::Base::find_for_create_modify
...uot; it from the database and update the "attributes=". If there is no such object, "new" it with the attributes I''ve got from the form. After I''ve wrote such code the third time, I came up with this more general solution: class ActiveRecord::Base def Base.find_for_create_modify(key, params) old_one = find(key) unless key.nil? if old_one result = find key result.attributes= params else result = new params end [result, old_one] end end But I think, I can''t be the first one, facing this problem. So I wonder if there might be a more ruby/rail...