Archive for the ‘Knowledge’ Category

Jul 28

Ruby version manager is a great tool that allows you to easily have multiple versions of Ruby. For Unix-based environment, there is RVM and for Windows we have Pik. This post will take you to have a quick look on Pik.

May 28

We are going to demonstrate a simple Rack Middleware use in Rails.

Apr 27

The named_scope method, which was introduced since Rails 2.1, allows us to do finds in a more elegant and comfortable than it was in use also make the code that we make more DRY.

Apr 14

While Rails itself already provides a lot of libraries that facilitate us to develop great web applications, but often we still need other Ruby libraries. Lucky for us because Ruby has rubygems that has become the standard format for library distribution.

Mar 03

Since Rails 2.3 released, a new try method was introduced. This new handy method allows you to invoke a method on a object without having to worry a NoMethodError exception will be raised. If the receiving object is a nil object then nil will be returned.

For example, there is no user with login “wolfman” so user.email will raise NoMethodError

user = User.find_by_login("wolfman")
user.email

You can avoid NoMethodError using try

user = User.find_by_login("wolfman")
user.try(:email)

More documentation on try.

Feb 08

Here is the problem, you need to merge some works from “stable” branch in “repo1″ to your current “master” branch. Below are the steps you do.
First of all, add a remote repository

git remote add foo git@example.com:foo/repo1.git

then download objects and refs from that newly added remote repository

git fetch foo

now checkout the branch which will you merge

git checkout --track -b stable foo/stable

swith to “stable” branch and check that everything is good to go

git checkout stable

then you move back to your current directory

Jan 16

Thanks to the guys that build BrowserCMS, our lives has just gotten easier!
No longer we have to stick with Radiant, BrowserCMS is, we think, easier and more robust.

This post is a simple getting started guide, that will help you to:

  1. Install the BrowserCMS
  2. Create a new page
  3. Add text content to the newly created page
  4. Publish your page
Dec 14

We have done multi-language feature for several Rails applications in the past, using gettext, gibberish, gibberish_db, etc. In this blog post I want to share the latest multi-language feature we built for our Netherland client recently, using Globalize2 plugin and Rails built-in I18n.

We used I18n for all our static contents, it’s a piece of cake. And all the client needs to do is to update that ymls files. For dynamic contents, we use Globalize2.

Dec 03

About a month ago one of our development teams is fortunate enough to have the chance implementing ServiceMerchant plugin
It is a plugin that makes use of ActiveMerchant, but designed specifically for recurring billing / subscription payment requirement.

As with all other gems, the best way to understand a gem, besides asking shifu Google, is to dig into the gem code itself and find sample apps, example usage, test units, etc

It’s pretty straightforward, and yet I feel like wanting to share some interesting things:

Nov 18

Probably you already know about n+1 queries problem, read this post if you want to learn how to detect those kind of queries.