ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Rails项目中jRuby与Scala的交互

Rails项目中jRuby与Scala的交互

原创 Linux操作系统 作者:jieforest 时间:2012-06-24 08:14:57 0 删除 编辑

The JVM is awesome.


But back to the topic of this post: We’ll see how you can leverage both Scala andJRuby in one project. Each will doing what it does best:


1. Ruby will handle the FAST frontend development as one of Ruby’s strong points is obviously Rails which made it so popular. Though there are people implementing APIs in ruby, if you need pure performance, you may need some other lang (vide airbreak, twitter…).


2. Scala will be doing all the heavy lifting including some of our existing code which interacts with zookeeper or uses Akka actors to crunch some numbers.


Another great point here is the reuse of our existing scala codebase which has some nice libraries we’ve implemented during our day-to-day. Anyway, let’s see some code!


Start out with a plain Rails 3.2 project


You know the drill. rvm, ruby, rails new. The only difference here is that we’ll use JRuby right from the start here, so:

CODE:

# get JRuby and start a new rails app
rvm install jruby && rvm use jruby

gem install rails
rails new scala-on-railsJRubify it!

Next we’ll add some more dependencies to our Gemfile:

CODE:

# jruby dependencies in Gemfile
gem 'jruby-openssl' # simply required
gem 'jruby-scala' # a jruby scala bridge
gem 'warbler' # to create a war file that we'll deploy layer

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/301743/viewspace-733665/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-04-23

  • 博文量
    443
  • 访问量
    508035