Take the 2-minute tour ×

I am trying to build a small app that tests my ruby code. I googled it but not much help(may be wrong selection of words). I am trying to create functionality that what does codecademy/ codeschool/ tryruby sites provide. They provide an integrated environment to run code online. I am not able to find from where to start for this, i.e why no code this time :( . Just need to know what specific technologies/ links I have to dig into for this feature.

Please provide any online source for reading if exists for this kind of feature.

share|improve this question
Go step by step, make a webpage, then make a server that execute ruby code, then use some Ajax to send data from your webpage to your server that would render the result without reloading the page. You're good to go. –  oldergod Mar 7 '13 at 8:31
@oldergod Only ajax will be sufficient or any other library is coming for this kind of feature ? over which i can create my stack then ? –  Trialcoder Mar 7 '13 at 8:37

2 Answers 2

up vote 1 down vote accepted

Cannot give all the steps, but the basics are clear (example for Ruby) :

  • Create a basic front end - could be just a big textarea form and a submit button
  • On the server, get the content of the form, execute it using eval and return the output to the page (with a simple erb)
  • If you want it to be sort of interactive, you can replenish the form with what was already there.

After, it can be time to play with the interaction (doing it in a ajax style to avoid the refresh and give a better experience), but that is icing on the cake, I would start with the basics above.

Warning : executing arbitrary code sent by a end user can (and will be) dangerous. This looks more like an experiment, if it become more, be sure to have your security well check (you are giving me bascially the right to execute any code I want on your server).

Security in the context of executing arbitrary code is a large and complex subject. To start with something :

  • Your problem is akin the "Code injection" problem - except that you are actually opening the door. Basic example : what if I submit instruction that are halting the process ? Of if I start deleting all folders on your server machine ?
  • Your may want to look at Ruby safe level
  • Better yet, look at Sven Fuch "Safe mode" for parsing and executing code

Your objective should be to "sandbox" the execution of the code completely : make it run in an apart dedicated process (or even VM), that could in the worse case be destroyed without impacting the others, with very limited access to resources.

Good luck !

share|improve this answer
what type of security features I need to look while creating such stuff (better if u provide something in rails terminology as I am implementing this thr) –  Trialcoder Mar 7 '13 at 9:13
I updated my answer accordingly. –  Martin Mar 7 '13 at 9:52

If you want to do this for ruby, you could also checkout the source of tryruby.com. See https://github.com/Sophrinix/TryRuby (it is not the source of the current version).

It seems that repo is not too uptodate, but it could serve as a starting point, or one of the forks will.


share|improve this answer
Thx Sir..it will really going to be a good place to start..although I am looking if you could update your answer little more as I am a starter with rails..so have very less idea where to search and find help for this :) –  Trialcoder Mar 7 '13 at 10:28

Your Answer


