Wes Gamble wrote:
All,
I have a view component that I would like to generalize.
What are the practical differences (if any) between using
@object.send('xyz')
and
eval("@object.xyz")
to dynamically get at an object's attributes?
Thanks, Wes
Short answer: The first is much better from a security point of view (image what @object.xyz could contain). If send doesn't have enough functionality, investigate instance_eval: http://corelib.rubyonrails.org/classes/Object.html#M001079