Blog (tips)

@fredwu 14 years ago | 1 min read | no comments
If you are using rake spec to run the specs. Try using spec spec instead! It avoids doing some preliminary tasks and therefore is quicker to execute. You can verify the difference using Unix’s time command, i.e. time spec spec and time rake spec.
@fredwu 14 years ago | 1 min read | no comments
Did you know, you can perform advanced search queries on GitHub? For example: ruby AND (textmate OR tmbundle) The above query will search everything containing ruby, as well as either textmate or tmbundle. Unfortunately at this stage the GitHub API does not support it. I’ve opened a ticket here.
@fredwu 14 years ago | 2 min read | no comments
Web applications normally have many forms. Building forms is always a mind-boggling task because it involves repetition and chaos. A shortcut is to use a form builder / DSL, such as Formtastic. As I am using Rails 3, and the Rails 3 port of Formtastic isn’t complete yet, I thought I’d just use the plain vanilla Rails built-in form helper. First of all, I am using Haml instead of ERb. Already, I got the out-of-box clean looking Haml markup. Some of you might not be aware of the fact that Rails...
@fredwu 14 years ago | 1 min read | no comments
So we want to dynamically instantiate an object (i.e. convert a string to a class constant). Instead of doing this: @dynamic_var = "User" eval(@dynamic_var) You can do this: @dynamic_var = "User" @dynamic_var.constantize See more about the constantize method in Rails’s API.