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, 7:28 am, Ritvvij <Ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.
On Jun 21, 1:30 pm, Ritvvij <Ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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> On Jun 21, 7:28 am, Ritvvij <Ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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.
eval works! :-) Thanks you On Jun 21, 7:38 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jun 21, 1:30 pm, Ritvvij <Ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > > On Jun 21, 7:28 am, Ritvvij <Ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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.
Ritvvij wrote:> eval works! :-) > Thanks youIt 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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.