I am pretty much new to ruby. How can we run a html embedded ruby code on our local machine.? I have ruby 1.8 installed on my machine. Do I need to install rails too for running that html with ruby code ? I got stucked ..
How to execute a html embedded ruby code on local machine
1.8k views Asked by Rak At
2
There are 2 answers
1
On
I hope this will help you. Try this. http://www.thegeekstuff.com/2009/10/ruby-hello-world-example-how-to-write-and-execute-ruby-program-on-unix-os/
To evaluate the Ruby code manually you can use the
erb
command.Given a
index.html.rhtml
file with the following content:Running:
Results in a
index.html
file with:This file can be viewed in a browser.
Another option is to use a web server to convert and serve the files. Here's a one liner starting WebBrick on port 3000 (assuming a
index.html.rhtml
file in the current directory):Pointing your browser to
http://localhost:3000/index.html.rhtml
should show the page.