views:

64

answers:

4

Hi everyone! Is it possible to call a ruby method inside javascript? One way of implementing it is via ajax calls, but is there a way I can embed that ruby function inside the js file and call it just like calling any other js function?

+1  A: 

Assuming you want the JavaScript to run in a web browser: No. Browsers don't have Ruby engines built in.

David Dorward
+1  A: 

No. Not without using Silverlight Dynamic Languages (or similar plugin) to act as a vessel for the language.

Even then, it's not embedding into JS, it's just adding another possible language to the <script> tag.

Matt
+1  A: 

I think you want something like RubyJS. This is a port of Google Web Toolkit to Ruby. Essentially it will let you write Ruby code that is compiled into JavaScript then run in the browser.

Matthew Flaschen
A: 

For Rubyt there was http://hotruby.yukoba.jp/ but it seems like the project stalled.

Julik