ActionController::Base.helpers proxy

Tidbit from RailsCast 132:
ActionController::Base.helpers is a proxy object you can use to access Rails view helpers, outside of views, e.g.:

1
ActionController::Base.helpers.pulralize(products.count, ‘product’)

RSpec view tests and url_for

Ran into a problem with RSpec when trying to create a spec for a view that used an ActionView url helper that required additional parameters to generate the url.

route.edit_page ‘:site/edit’, :conditions => { :method => :get }, :controller => ‘webpages’, :action => ‘edit_page’

The above route sets params[:site] which is later used for url generation (using, [...]

CSS floats

This is just about the best write-up on floats that I have seen.

ActiveRecord eager-loading thru multiple associations

I just found out how to do something I have been wondering for a long time: :include syntax to eager-load through multiple associations. In the rdoc for class ActiveRecord::Associations::ClassMethods I discovered you can nest include statements in hashes as follows: If for example table_a has_many table_b and table_b has_many table_c and table_c has_many table_d:

Model.find :first, :include => [...]

Safari caches IFRAME src=

This just bit me again so I thought I would share it.
Safari is doing over-zealous caching of IFRAMEs.  Once it sees an IFRAME, it remembers the value of the src= option for the IFRAME with that name= or DOM ID and refuses to ever look at it again.  No matter what you change the src= [...]

Installing Ruby MySQL gem on Mac OS X Leopard

Thanks to this post, I discovered how to install the MySQL ruby gem on Mac OS X:
You must be using the x86 variant of MySQL, not x86_64, apparently.  Then:

sudo env ARCHFLAGS="-arch i386" gem install mysql — \
–with-mysql-dir=/usr/local/mysql –with-mysql-lib=/usr/local/mysql/lib \
–with-mysql-include=/usr/local/mysql/include