Basically I want to store a Ruby Block into DB and use them.
One could ask why - reason being, i want my users to be able to post / upload a block code - which could be executed to fetch a desired result for their problem on the data we might have.
So you don't want to store ruby blocks. You want to store code. This is easier. Just store the code as a string. And then later you can eval
that string, effectively executing the code.
Now you have to solve a hard problem: how to prevent users from posting malicious code (or how to sandbox them). But that's out of scope here.
First, store your code as a string (the ruby2ruby gem may helps you). When you need to execute this block, retrieve it from DB, and use the "eval" method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With