for some models I found that it’s easier to share the controller new and
update code just to share the view code. At the front of every such
action function I have to lookup if the object already exists, if so
“find” 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
def Base.find_for_create_modify(key, params)
old_one = find(key) unless key.nil?
result = find key
result = new params
[result, old_one] end
But I think, I can’t be the first one, facing this problem. So I wonder
if there might be a more ruby/rails-ish way to accomplish this.