Rails项目中jRuby与Scala的交互

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-rails JRubify 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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/301743/viewspace-733665/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值