As those of us living and working in China know,sometimes the internet can be troublesome . At some point last month, installing gems from the command line - something we do almost every day if not many times a day - no longer worked seamlessly. For whatever unknown reason, the rubygems production server is currently inaccessible or extremely unstable from within mainland China.

In discussions with the gzruby group, we tried to find workable solutions to this problem. One idea is to set up a reverse proxy. This solves the issue, but installing gems is still really slow. Another proposal is to set up a mirror, as described in this post by sachin. But rather than set up a local server, why not set up the proxy somewhere the greater community can use it.

Thus, was born.


Add the following line to your Gemfile:

source ""

And change your ~/.gemrc to something like this:

gem: --no-rdoc --no-ri


The project was started by fnando. Our fork contains cosmetic changes only. If you want to set up your own proxy/cache, we recommend that you start from this fork by akitaonrails.

The app itself is a simple rack app that either serves a cached version of the gem, or fetches the gem from So the server on which you install must have access to this address.

If you already have a rails server running passenger on any VPS outside of china, setup is very easy. Simply clone the project into a new directory, and add a config to apache or nginx just as you would for any rails app.

Posted by adevadeh 28 Nov 2011 at 05:22AM

gzruby meetup #3

Image of Seb with a slide

Thanks to everyone who attended the gzruby meetup last wednesday night. It was great to get a chance to meet up with our ruby friends and we also met a lot of new people. It‘s exciting to see how the community is growing as we gain new members and introduce more people to the joys of ruby.


The presentations included:


  • Launch of, the GZRUBY rubygems mirror
  • Real Life Rails Scaling, by Seb. Scaling your app, your team ... yourself. (slides)
  • method_proxy - some fun with ruby's dynamic programming, by Jev. A look at how we can utilize ruby's meta-programming features to get deep insight into our code. (method_proxy sample code, slides)
  • Cloud Service API design, by Chance Jiang

Really looking forward to the next meeting, planned for Jan 18, 2012! See you all next year.

让我们一起期待下一次gzruby聚会,2012年1月18日(预计)。 明年见!

Photo by littlepxy


Posted by adevadeh 28 Nov 2011 at 03:39AM

Rails on Campus: 华农版 - Session #2

Group photo from RoC Session #2

Last week we had another great Rails on Campus session with the students at South China Agriculture University 华南农业大学. Again, it is really great to see how motivated the students are. We are really impressed with their level of knowledge in web-development and how quickly they can pick up the topics we cover.

上周我们与华南农业大学的同学们度过了一个愉快的周末 -- Rails on Campus 的第二次活动。 非常高兴能够再一次感受到同学们的积极。大家对网页开发的扎实知识以及对新知识的快速吸收能力,给我们留下了深刻的印象。

This week the lesson covered the following topics:


  • Review Rails app structure, rails commands to create the DB and start the app
  • Basic resources and RESTful routes: index, show, create
  • Adding an ActiveRecord association: belongsto, hasmany
  • ActionView#form_for and building a nested form

We did this by adding a replies feature to our simple miniblog app. To follow along, you can grab the code at github RoC Lab #2.

Thanks to everyone who helped out, especially our speakers Rain Chen and Mysen Huang. We look forward to the next session where we will cover users and sessions.

非常感谢过来帮忙的各位,尤其是我们的 Rain ChenMysen Huang 两位主讲者。希望我们的下一次活动会为同学们带来更多的主题分享。

Rails on Campus is a program started by Leon Du and Shaokun Wu, 2 ruby developers in Guangzhou, China. The idea is to build a good set of material for introduction courses that can be used to teach Rails on college campuses. College students are often not exposed to newer technology, and are left to learn on the job. The goal of this program is to introduce students to the world of open source development frameworks to help prepare them for a good job.

Rails on Campus是由中国广州两位Ruby 开发者, Leon Du和Shaokun Wu 发起的。活动的初衷是为大学Rails的教学积淀一些有价值的学习材料。大学学生接触新技术的机会不十分多,而常常要上到工作岗位才开始学习。希望通过这次活动,可以为同学们带来更多开源的开发框架,以此为将来的好工作更好地准备自己。

Rails on Campus is sponsored by:

Rails on Campus的赞助团队有:

Posted by adevadeh 28 Nov 2011 at 03:11AM

Rails on Campus: 华农版

Last week we had our first Rails on Campus session at the South China Agriculture University (华南农业大学). We had an excellent turnout of 50 or 60 top-notch students. We were really impressed with their knowledge of web development in general, and their enthusiasm to learn new things.

上周末我们 Rails on Campus的第一次活动在华南农业大学展开了。大家反应热烈,有5,60个学生参加了我们的活动。同学们对知识的渴望给我们留下了深刻的印象,参加的同学基础知识也非常不错。

The first session focused on:


  • Setting up the Rails environment on your computer
  • Learning about the origin of Rails and ruby
  • Creating a new Rails app from the command line and adding a simple scaffold

We built a working web app as a demo in about 10 minutes, starting from rails new and finishing with a nice looking miniblog.

The only problem was the recent issues we've been having accessing rubygems from China. This made it very difficult for the students to get a Rails environment working on their own laptop. We hope to have a good solution for this problem before the next session.

For our next session, we'll continue to build on the same application by adding a reply feature.

Here are the links from session #1



Rails on Campus is a program started by Leon Du and Shaokun Wu, 2 ruby developers in Guangzhou, China. The idea is to build a good set of material for introduction courses that can be used to teach Rails on college campuses. In Guangzhou, and many other areas around the world, college students are often not exposed to newer technology, and are left to learn on the job. The goal of this program is to introduce students to a new world of open source development frameworks that are quite popular around the world. Not just Rails, but also things like Node.js or Python/Django.

Rails on Campus是由中国广州两位Ruby 开发者, Leon Du和Shaokun Wu 发起的。活动的初衷是为大学Rails的教学积淀一些有价值的学习材料。在广州,以及世界的一些其他的城市,大学学生接触新技术的机会不十分多,而常常要上到工作岗位才开始学习。希望通过这次活动,可以为同学们带来更多热门的开源的开发框架,以此为将来的好工作更好地准备自己。不单单是Rails,以后我们可能还会涉及到像 Node.js 或者 Python/Django 这样话题。

Rails on Campus is sponsored by:

Rails on Campus的赞助团队有:

+ gzruby - The Guangzhou Ruby Group
+ Kudelabs
+ Beansmile

Posted by adevadeh 17 Nov 2011 at 03:15AM

Join Us for the third GZRUBY meetup


时间过得飞快,Rubyist party 又来了,你准备好了吗? 有主题想分享的同学请踊跃回复啦!

时间:23/11,  7:30 PM
地图Kudelabs 明月一路59号, 汉苑 西塔601室

Dear Rubyists,

How time flies, it's party time again, are you ready?
Anyone want to share something, please reply!

When: 23/11,  7:30 PM
Where: Kudelabs, 明月一路59号, 汉苑 西塔601室
Metro: Exit A Wuyangcun station

So far, we have  a few talks planned: @shaokun will talk about Rails Engines. @seb will discuss large scale rails apps and scaling issues, and @adevadeh will talk about solving the rubygems problem. 

Posted by adevadeh 17 Nov 2011 at 02:53AM

Some Fun with Ruby Abstract Syntax Tree

For a while, I've been interested in gems that provide access to Abstract Syntax Tree (AST) representation of Ruby code, and potential possibilities they open. Just a couple days ago this interest was triggered again. The question that arose at the moment was:

  • say, we're facing somebody else's lengthy, sophisticated and rather unfamiliar code which we're planning to reuse. How do we find out where the code may be cache'ing results in instance variables - therefore, possibly, causing unplanned and undesired side effects?

Perhaps, we could convert the given piece of Ruby code into AST and then list all lines that correspond to instance variable assignment nodes... This felt like an interesting exercise so I ended up writing a little code snippet for that.

A few other possible AST uses, I thought, could be:

  • listing all methods defined in a specific file;
  • listing all method calls in a given class or method (e.g. to figure out external dependencies for refactoring or unit-testing purposes);
  • listing class variable assignments.

So, the initial script evolved into a more generic parsetree_locator.rb utility (note: requires 'ruby-parser' gem; also, only tried it on MRI Ruby 1.9).

Let me present a few examples of how the utility works.



Say, we have the following Ruby code in 'example.rb' file:

module M
  class C
    def meth
      @a = 2
      b = 3

    def call_meth

    def another_meth
      @n = 95

1) List all instance variable assignments - "iasgn" AST nodes:

$ ruby parsetree_locator.rb "iasgn" "example.rb"


Line nr | Module, class, method                              | Code
4:      | module M, class C#meth                             | @a = 2
13:     | module M, class C#another_meth                     | @n = 95

2) List all defined instance methods - "defn" AST nodes:

$ ruby parsetree_locator.rb "defn" example.rb


Line nr | Module, class, method                              | Code
3:      | module M, class C                                  | def meth
8:      | module M, class C                                  | def call_meth
12:     | module M, class C                                  | def another_meth

3) List all method calls - "call" nodes:

$ ruby parsetree_locator.rb "call" example.rb


Line nr | Module, class, method                              | Code
10:     | module M, class C#call_meth                        | end
15:     | module M, class C#another_meth                     | end

-- seems like the line numbers are slightly off in this case. The author of 'ruby_parser' gem mentions that it may happen; the results seem reasonable most of the time, though.

Hope that somebody else finds this utility useful as well, enjoy! parsetree_locator on GitHub

Posted by Jevgenij Solovjov 24 Oct 2011 at 07:52AM

Join us for the second gzruby meet up!

The second meeting of the gzruby group will be held in the Kudelabs Offices Wed, Sept 21 at 7:30PM.

Anyone in GZ who uses ruby, or is interested in ruby is invited!

For more information, join the mailing list:


本周三我们将会在老地方(Kudelabs)迎来又一个Rubyist party,大家准备好了吗? 为了照顾大家出行,避开下班高峰期,我们决定这次聚会稍晚(晚7:30)开始, 以便大家就餐,来到后可以直接进入主题进行讨论。 聚会预计持续1.5小时,出去开场介绍和自由讨论之外,应该有一个小时左右留给大家做发言, 目前我们已经有来自Sooyoung团队的Padrino主题,此外我们团队也将带来一个主题, 分享我们项目开发过程中使用的一些gem/工具,现在还留有时间可以准备1-2个主题, 大家有想来做分享的请踊跃回帖阿!

Hi all dear rubyist in GZ, it's party time again!

We'll have the next rubyist party on Wednesday(21th Sept) this week at 7:30 pm, same place at Kudelabs. To make it more convenient to all of us, we decide to get start a little later, so everyone can have dinner before come to the party, then we can get straight into the topics faster. We planned to have the event last in around 1.5 hrs, endding at around 9:00 pm, before everyone is sleepy ;-) besides the introduction/public discuss section, we should have about 1 hours for topics. We've already had Padrino from Sooyoung's team, our team will share a topic, something like "share our toolbox", so we still have time for 1-2 topics, if you have something to share, please post it here :)

Posted by adevadeh 19 Sep 2011 at 08:08AM

how to make CI tool hudson work for rails project on ubuntu

hudson is awesome CI(continuous integration) tool. 

We want to install it on our ubuntu server to do CI for our rails projects.

Here are the steps of how to make it work:

1. ssh username@servername, to login remotely to your ubutu server.

(After you install a brandly new ubuntu on the server, you will need to sudo apt-get install openssh-server, then you can ssh it from your laptop)

2. install hudson on the ubuntu server, here is the instructions:

(the good news after you finished the installing is, hudson is already so system daemon that will be auto-started when ubuntu reboot.)

(after installed hudson and reboot ubuntu server, open a web browser, access http://serveaddress:8080/, you can see the lovely interface of hudson. Then you need to install several plugins for hudson, like ruby, rake, git etc, this can be easily done through hudson UI)

3. install ruby on the ubuntu server, run the following command

sudo apt-get install ruby

(this will install ruby 1.8.7 as default)

4. after login ubuntu server on your laptop, run this command on the terminal of your laptop to act as the hudson user auto-created by the hudson installation.

sudo -Hiu hudson 

(you have to act as hudson user, because the next step is to install rvm, if you install rvm under another account, hudson account will not be able to execute rvm command.)

5. install rvm, here is the instructions:

(make sure you are using hudson account on ubuntu, by this way, the rvm will be installed under hudson directory)

(you will need to create a .bashrc file to $HOME dir, and add a this line to that file

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function)

5. rvm install ruby-1.9.2

6. rvm --default ruby-1.9.2


then we are almost there!


7. How to set Hudson to use to send emails after a build failed?

go to hudson config page

smtp server:

username: ******

password: *******

usessl, true

smtp port: 465

charset: utf-8



8. I run into another problem when trying to check out a project.

We used "externals" feature in svn 1.6, but when I build a project for the 1st time, the code in external is not checked out.

My solution is in the config screen of the project, at the section setting svn urls, press "add" to add a location.

then fill in the svn url of the external codes,

then fill in correct local directory that the external codes should go in.

then this problem is bypassed. 


9. set the build part in project:

a. select "execute shell"

b.  add the following lines:


# Environment setup

#source "$HOME/.rvm/scripts/rvm"

# Use the correct ruby

rvm use 1.9.2@gemsetname

# Do any setup
# e.g. possibly do 'rake db:migrate db:test:prepare' here
# bundle install
# Finally, run your tests
10. when using emai-ext plugin, the email content should be:
Check console output at $BUILD_URL to view the results.
Below is the raw output:
${BUILD_LOG, maxLines = 100000}

Posted by 张晓峰 01 Jul 2011 at 09:03AM

how to solve " cannot open shared object file" when using RVM in red hat

On linux server, we installed glpk library. then we installed rglpk gem under a gem set through RVM.

We try to use rglpk in our soft, but got this error: cannot open shared object file: No such file or directory -    

If we install the rglpk gem under system ruby paths, (by using sudo gem install rglpk), rglpk will work as expected.

From the error message, we deduce the problom is rglpk can't find the file.

Then we checked the usr/local/lib dir, we find that file is actually there, what's wrong?

readelf -a

Using this command to check the content in the binary file rglpk-0.2.4/lib/ and comparing this file the from system ruby, we find that library path is wrong in RVM's

In RMV's file, the library path is ruby/.rvm/gems/..../lib

In system file, the library path is usr/local/lib

So we make a link from RVM's library path to the correct library path usr/local/lib like this:

ln -s /usr/local/lib/

Finally, this solved the issue, and rglpk works again!

So the reason is when we run gem install rglpk under a specific gemset under rvm, the library path indicated in file is wrongly configured.

Posted by 张晓峰 22 Jun 2011 at 06:00AM

Rails on Campus Wrap-up

After 2 great sessions of Rails on Campus: 华工版, we'd like to thank everyone who took part in helping to plan and organize this event. We learned a lot from the experience, and we hope the attendees did as well. We plan to take our materials from this first run, refactor, and put on a better program next year!

Before we close out for the year though, I wanted to go over what you can do to continue learning on your own.

Install Rails - Download and run the installer. It will install everything you need to get started writing your own Rails apps (ruby, git, rubygems, rails).

Get the demo code - Clone the project and get it running on your computer . git clone git:// cd roc-demo2 rake db:migrate rails s open http://localhost:3000

Write some code - You can use any text editor to write code, but its much easier in a real code editor like Notepad++. It's free, give it a try.
http:// - Take a look at the Rails Guides for more in-depth tutorials - Another great resource with tons of tips and information

Share with the world - A free service to host your amazing Rails app! It works right from the command line and in 5 minutes you have a public site that you can show to anyone.

Just Do It

So now you have no excuse. You have the tools, you have the code, you have the servers. Go write an inspiring app and make us proud!

Posted by adevadeh 09 Jun 2011 at 09:24AM