Please post code correctly on the forum …
Some items, I don’t know if it is your problem:
-
You do not need eval here as your code is already being evaluated by Ruby’s interpreter.
-
You are not using defensive coding practices. What if
currentItemPID is
“”` ? … If it is empty, should you be trying to find the object by persistent_id ? -
What is
@entityAD_name
? Please remember that the model scope is a shared scope, so all attribute dictionary names should be unique and it is probably best to use the unique name of your extension.
When you post a complex issue this this, in order to understand, it is best to provide a same sample model to test with. Also, there are a number if instance variables in use that we do not know what they are.
Your introduction does not actually state what it is that the code is attempting to accomplish.