busy at work

May 27, 2010|1 Min Read|Comments|

Busy at work…


[Rails] Use App_Config For Your Application Specific Configuration

May 25, 2010|1 Min Read|Comments|

A simple Google search will reveal that there are a number of different App _ Config plugins for Rails. After comparing them side by side, I have decided to use the one by Christopher J. Bottaro . It features: simple YAML config files config files support ERB config files support inheritance access config information via convenient object member notation I just fixed a bug last night (which was pulled in to the main repository) where it could throw errors when used as a Rails plugin (i.e. via…


[Rails Tip] Model Attributes Not Updating? `reset_column_information` To the Rescue!

May 25, 2010|1 Min Read|Comments|

So you were wondering why some of your model attributes weren’t updating properly? Well, it is perhaps because the db schema has changed but the changed schema has not been passed onto ActiveRecord, as is often the case in DB migration. Taken from the ActiveRecord documentation: Resets all the cached information about columns, which will cause them to be reloaded on the next request. The most common usage pattern for this method is probably in a migration, when just after creating a table you…


[jQuery Tip] Traverse/Parse HTML String

Apr 28, 2010|1 Min Read|Comments|

When you are getting an HTML string from an external source (e.g. from an AJAX get result) and you want to rip out a certain part of the HTML source, you need to make sure that the ‘certain part’ is not at the top level of the HTML source. For example, we have the following HTML string: If we want to get the first paragraph element by using: The above code won’t work, because the p tags are at the top level. Instead, we can simply wrap the HTML source with a div tag and that’ll do it. :)


[Rails Tip] DataMapper M:M Association Bug and Workaround

Apr 26, 2010|1 Min Read|Comments|

It was confirmed that DataMapper is incorrectly setting table names in SQL JOINs . So for instance, the following code would generate an SQL error: There is a workaround, however the workaround requires manual looping of the dataset thus produces N+1 queries. But at least it works. ;)


[Rails Tip] DataMapper Timestamps Bug and Workaround

It has been confirmed by DataMapper ’s core developer Martin Gamsjaeger (snusnu) that it is a bug. In short, created_[at|on] can be manually overridden, but updated_[at|on] cannot. The workaround is simple, do it in two steps, for example: Please check the bug ticket to see when it’s getting fixed.


[Rails Tip] Run Specs Faster!

Apr 09, 2010|1 Min Read|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 .


[Rails] Run Queued Tasks Using 'delayed_job', Now With Intervals!

If you don’t already know, ’ delayed _ job ’ is a database based asynchronously priority queue system extracted from Shopify . I was seeking for a lightweight, easy to use solution for queueing tasks, ‘delayed _ job’ fits the bill almost perfectly. ;) One thing we needed to do for a Rails 2 project at Envato , was to queue the tasks and to run them one after another, at a set interval. 'delayed _ job’ unfortunately doesn’t come with this feature. So, instead of searching for more complicated…


i need textmate 2 or a 3d monitorprojector to

Mar 17, 2010|1 Min Read|Comments|

I need Textmate 2 (or a 3D monitor/projector) to come out sooner, otherwise there will be a day where I will just be totally lost in dozens of windows.


[Rails] MongoMapper on Rails 3 Master, Undefined 'to_key' Method

Mar 17, 2010|1 Min Read|Comments|

Rails 3 has recently renamed key method to to_key , which consequently rendered MongoMapper unusable. You might see an error that looks like: After some twiddling I’ve submitted a patch to address this issue. Feel free to pull my fork until the fix makes its way into John Nunemaker’s main repository .