In an effort to understand the question (not having used class_eval) I
found the following link that suggests, rather non-intuitively, that
you should be using instance_eval rather than class_eval.
sorry for mistake not Assignee.assignee_name
Assignee.find(1).assignee_name
Do you mean that you have fixed the problem by that change, or that
you had a mistake in the question you asked and with
Assignee.find(1).assignee_name it still fails?
Please don't top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in previous message. Thanks.
I thought class_eval method would permanently add assignee_name method to
Assignee instance object and i can access from other action too.
I think it will, but only when you execute the class_eval code.
Permanent means of course until you restart the server or reload the
Assignee class. Since in development mode classes are reloaded at
each action request it will not hold from one request to the next, if
that is what you are trying to do. Even in production this is a bad
thing to do as you never know when a server might get restarted and
loose the data. Not to mention the fact that once in production
successive actions are not necessarily even run by the same computer.
If you want retain information from one action to the next then put it
in the session or in the database, or in a hidden field in the
intervening view.
I think Chirag Singhal's suggestion is better though unless there is
some reason you cannot use it.