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 开发者_StackOverflow社区file and call it just like calling any other js function?
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.
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.
Assuming you want the JavaScript to run in a web browser: No. Browsers don't have Ruby engines built in.
For Rubyt there was http://hotruby.yukoba.jp/ but it seems like the project stalled.
精彩评论