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.
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
Posted in Knowledge
Tags: browsercms, cms, rails
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:
- Install the BrowserCMS
- Create a new page
- Add text content to the newly created page
- Publish your page
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.
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: