- Rails gotcha: if you want to use a column in the database to order your records, don’t name that column “order”. Plus, you can get this functionality almost for free by using
acts_as_list, which uses a column named “position.”
- If you are referencing RFC 822 “Internet Message Format” to do such things as validating the format of an email address, that RFC has been replaced with RFC 2822. The most notable change is that addresses are not valid if they do not specify the top level domain (.com, .net, etc.). Example:
- joe@pivotallabs — Not valid
- email@example.com — valid
We had to update validates_as_email to support this. We’ll submit a patch.
- Oh yeah… xpath is 1-based, not 0-based. That gets us every time.
- Most of us who have converted from Windows to Mac hate the Mac’s usage of the Home and End keys (move to beginning of file or end of file, respectively.) Here’s a trick to ‘fix’ them:
To make home and end keys work on a mac simply copy this into the specified file (DefaultKeyBinding.dict)
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
"^f" = "moveWordForward:"; /* Ctrl-f = next word */
"^b" = "moveWordBackward:"; /* Ctrl-b = previous word */
"^v" = "pageUp:"; /* Ctrl-v = page up */
"UF729" = "moveToBeginningOfLine:"; /* Home = start of line */
"$UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift-Home = start of doc */
"^UF729" = "moveToBeginningOfDocument:"; /* Ctrl-Home = start of line and select */
"@UF729" = "moveToBeginningOfDocument:"; /* Cmd-Home = staart of doc */
"UF72B" = "moveToEndOfLine:"; /* End = end of line */
"$UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift-End = end of line and select */
"^UF72B" = "moveToEndOfDocument:"; /* Ctrl-End = end of doc */
"@UF72B" = "moveToEndOfDocument:"; /* Cmd-End = end of doc */
Everything seems to work except firefox, sadly.
- We’re looking for the best search plugins for Trac. Suggestions?
- Rails: We often find ourselves adding
and return in our Controllers to avoid the dreaded
DoubleRenderError. It turns out that you can use
unless performed? instead:
render :template => "wrangler/monkey" if wrangle_monkey?
render :template => "wrangler/sleep" unless performed?
- Rails gotcha: with ActiveRecord.findXXX, you can specify query parameters such as
:include. But if you use those three together Rails will generate an incorrect query.
- Rspec 1.0 has been released.
Ask for Help
- Yahoo’s Geolocation service is broken after they released a new version if their code. Zip code searching in particular significantly broken — discussion thread here: http://tech.groups.yahoo.com/group/yws-maps/message/5468 — here is an example:
- Search for a zip code using the following URL: http://local.yahooapis.com/MapsService/V1/geocode?appid=YahooDemo&location=94102
- Result (notice the bad State and Zip tags):
<ResultSet xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps"
<City>San Francisco, CA 94102
<!-- ws05.search.re2.yahoo.com compressed/chunked Thu May 17 15:02:00 PDT 2007 -->
This is fixed! Thanks, Yahoo!