watch this  

the official mrchucho blog

The correct way to override ActiveRecord::Base#destroy

Posted 2008 Sep 30

In order to correctly override #destroy in an ActiveRecord model, you actually need to implement #destroy_without_callbacks like so:


def destroy_without_callbacks
  unless new_record?
    # do your custom stuff here, then save
  end
  freeze
end

Simply implementing #destroy will short-circuit the callback chain and skip the destroy method on any associations marked :dependent => :destroy.

comments (0)

Times Tables

Posted 2008 Aug 23

To help my daughter practice multiplication and to experiment with Google App Engine, I created a small app for doing your times tables.

http://times-tables.appspot.com/

I’m pretty impressed with GAE. It’s very easy to use, the Mac App Launcher is helpful and the online Dashboard is well done. I especially like the ability to upload and stage multiple versions.

comments (0)

Next Image on AMO

Posted 2008 Jun 24

I’ve started the process of having Next Image hosted on the official Mozilla Add-ons site. Once it receives enough ratings, it can be nominated for the public site.

Please rate or review Next Image via it’s sandbox page:

Next Image :: Firefox Add-ons

comments (1)

Next Image Updated for Firefox 3

Posted 2008 Jun 23

I’m in the process of updating my extensions to support Firefox 3. Unfortunately, there were some significant changes in how extensions can be served. So, at this point, only my Next Image plugin is working. Also, it might not show up via the Add-ons manager “Find Update”, so please install it directly.

Project Page: http://www.mrchucho.net/pages/projects#nextimage

Direct Link: http://www.mrchucho.net/downloads/nextimage-0.9.xpi

Updated – My second extension, This Window, is now up-to-date and available, too.

Project Page: http://www.mrchucho.net/pages/projects#thiswindow

Direct Link: http://www.mrchucho.net/downloads/thiswindow-0.8.xpi

comments (0)

This is bbot

Posted 2008 May 29

This blog is powered by a custom blog engine I wrote in Rails. I call it bbot as an homage to my favorite Ruby irc bot, rbot.

I built bbot for two reasons: I wanted to build a completely RESTful application from scratch and I was tired of wrangling with Wordpress. bbot is simple; it does exactly want I need and nothing more. It supports all the basic blogging features: posts, comments, moderating, drafts, permalinks, etc. plus non-post static page (e.g. my about).

I’ve decided to make bbot available on github: http://github.com/mrchucho/bbot/tree/master. This way I hope to learn more about git and share bbot with anyone who might be interested.

comments (0)

Gmail prohibits attachments with "executable" files

Posted 2008 May 05

Since when does Gmail prohibit sending email with a .bat file attached? It won’t even send a Zip file that includes a .bat file.

Of course, executable shell scripts for other platforms can still be attached and sent. Apparently, even legitimate users require protection from the scourge of Windows batch files.

comments (0)

Tulsa Ruby Workshop

Posted 2008 Apr 11

If you’re in Tulsa or the surrounding area and want to learn more about Ruby (or just meet other Tulsa Rubyists) please attend the Tulsa Ruby Workshop Saturday April 26th from 10am to 4pm.

Hope to see you there.

comments (0)

Tip: Capistrano local_repository

Posted 2008 Feb 19
In the case where your application is deployed on the same server as your Subversion repository, it can be helpful to access the repository via the file system rather than over the network.

set :repository, "file:///path/to/repository" 

However your workstation (from which you’ll run Capistrano) will need to access the repository over the network. This is accomplished by setting that local_respository parameter. “local”, in this case, meaning your local workstation.

set :local_repository, "http://host/svn/repository" 

Thanks to an article on my host, Slicehost, for pointing this out.
comments (0)

The REST is History

Posted 2008 Feb 14

It’s all about the Rewrite Condition.

Rails page caching is great and REST is great, but together they can be confusing. Considering a resource “Posts”, Rails gives you the following routes:

  GET    /posts     {:controller=>"posts", :action=>"index"}
 POST    /posts     {:controller=>"posts", :action=>"create"}
  PUT    /posts/:id {:controller=>"posts", :action=>"update"}

If you have Apache configured with mod_rewrite to serve your cached pages (instead of sending them to mongrel, e.g.), then all of those routes appear to be requests for “posts.html”. The end result is that you can’t create or update the “Posts” resource. The solution, let Apache handle the GET requests and mongrel handle everything else:

RewriteEngine On
RewriteRule ^/$ /index.html [QSA]

RewriteCond %{REQUEST_METHOD} ^GET$
RewriteRule ^([^.]+)$ $1.html [QSA]

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]

comments (0)

Quick Mac Clone

Posted 2008 Feb 02

Boot your Mac using the “Mac OS X Install Disc”, then select “Utilities > Terminal…” to get a command prompt. With an external drive attached, run the following command substituting the name of the disk you want to clone (source) and the name of the partition onto which you want to place the clone (target):

asr —source /Volumes/Macintosh\ HD —target /Volumes/Clone —erase

This will do a fast, block-level bootable clone of your Mac. I use this all the time before doing any major upgrades or changes to the partition table.

comments (0)
atom rss