22 Nov 2010
Richard Huang
Memoization is an optimization technique used primarily to speed up computer programs by having function calls avoid repeating the calculation of results for previously-processed inputs. In rails, you can easily use memoize which is inherited from ActiveSupport::Memoizable.
Read More
Tags
performance
19 Oct 2010
Richard Huang
In a system like forum, the title and body is displayed on show page, but only title is on index page. You should use select in query to speed up the query and save memory.
Read More
Tags
performance
query
03 Oct 2010
Richard Huang
Do you always check if ActiveRecord's attributes exist or not by nil?, blank? or present? ? Don't do that again, rails provides a cleaner way by query attribute
Read More
Tags
model
23 Sep 2010
Richard Huang
If you want to generate different urls according to different objects, you should use the polymorphic_path/polymorphic_url to simplify the url generation.
Read More
Tags
view
helper
09 Sep 2010
Richard Huang
If you want to do a large data query such as finding all the 10,000,000 users to send email to them, you should use batched finder to avoid eating too much memory.
Read More
Tags
model
performance
task
02 Sep 2010
Richard Huang
There are a few posts told you how to integrate bundler into capistrano, but they are out of date now. After bundler 1.0 released, you can add only one line in capistrano to use bundler.
Read More
Tags
deployment
capistrano
bundler
30 Aug 2010
Richard Huang
Do you experience that your website renders slow due to loading a lot of javascripts, especially loading some third-party javascripts? Move script tags to the bottom of body can speed up the render of your website.
Read More
Tags
view
performance
assets
javascript
25 Aug 2010
Alvin Ye
Tags
search
view
23 Aug 2010
Richard Huang
I don't remember how many times I need to fetch current user in models, such as audit log. Here is a flexible way to set the current user in and fetch the current user from User model.
Read More
Tags
model
19 Aug 2010
Guillermo Álvarez Fernández
Use say_with_time and say in migrations will produce a more readable output in migrations. And if use correctly it could be a helpful friend when something goes wrong because normally it is stored in the deploy log
Read More
Tags
migration