Run Ruby Code Stored in DB

Hi,

I have a module which needs configurable rule. This piece of code,
something as small as, “current_user.chapter_id”, etc has been stored
in the DB. I fetch this code into the helper class and then need to
run it to generate an ID. How do i do it???

But of course its taking it as a string.

Is there something like REFLECTION?

On Jun 21, 1:30 pm, Ritvvij [email protected] wrote:

Is there something like REFLECTION?

Well you can use eval. However more often than not there is a better
way (that won’t let someone setup the rule rm -rf )

Fred

eval works! :slight_smile:
Thanks you

On Jun 21, 7:38 am, Frederick C. [email protected]

Ritvvij wrote:

eval works! :slight_smile:
Thanks you

It may work, but you must safeguard it so a malicious user doesn’t
make you eval “User.delete_all”! Be careful!

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]