Archive for the 'rubyonrails' Category

Scaling to a billion

« 30 May 2008 | 16:05 | railsconf 2008, rubyonrails | No Comments »

Guy created Warbook. Had to rewrite the application within three weeks of launch due to scaling issues.
So, figure out why it is slow:
- Started with Firebug net tab.
- mint had to go wouldn’t scale
- pl_analyse, iostat, io was a point of failure, MTop.
- pagination also caused the app to drag. Ditched it too. Worked around […]



EngineYard hosting

« 30 May 2008 | 14:10 | railsconf 2008, rubyonrails | No Comments »

use explain with /G to test queries and make sure they are using your indexes. all index columns must be left to right in column order or they are ignored.
Plugins:
Ferret is hated. Sphinx is better.
image science + monit clears some environment variables. solvable by setting env vars in configs.
don’t forget to set log levels to […]



OpenId 2.0 and Ruby on Rails 2.0.2

« 6 March 2008 | 17:05 | openid, ruby, rubyonrails | No Comments »

I just converted a website from the openid_consumer plugin to DHH’s open_id_authentication plugin and patched it for OpenId 2.0.
I found face’s port of Dr. Nic’s sample open_id_authentication app to be a useful starting point. I ended up chopping down the open_id_helpers class to this:
module OpenIdsHelper
# Pass optional :required and :optional keys to […]



Calling a rake task from rails code.

« 23 January 2008 | 13:52 | rake, ruby, rubyonrails | No Comments »

1) Require rake and load the rake files containing the tasks and dependencies you want to run:
require ‘rake’
load File.dirname(__FILE__) + ‘/../vendor/rails/railties/lib/tasks/misc.rake’
load File.dirname(__FILE__) + ‘/../vendor/rails/railties/lib/tasks/databases.rake’
2) invoke the task
Rake::Task[”db:test:prepare”].invoke



delete and delete_all don’t trigger callbacks

« 10 January 2008 | 14:01 | rubyonrails | No Comments »

I’m sure this isn’t earth shattering to anyone but I had forgotten about it and it caused me some head scratching yesterday.



Base classes get stored by ActiveRecord with type = NULL when using STI…

« 10 January 2008 | 13:53 | active record, rubyonrails | No Comments »

So you make sure you take that into consideration when crafting find_by_sql queries on STI tables.
For example when looking for all but one type in the table:
AND ( g.type != ? OR g.type IS NULL )



XMLRPC::Client#do_rpc: Client-Type charset param incompatible with some blog’s MetaWeblog APIs

« 17 September 2007 | 21:00 | magnolia, rubyonrails, xmlrpc | No Comments »

We recently added an automated posting feature to Ma.gnolia which uses XMLRPC and the MetaWeblog API to post a summary of a user’s bookmarks for a given time period to their blog. To implement the MetaWeblog client functionality we wrote a lightweight wrapper around Ruby’s XMLRPC::Client class.
After we released the feature to beta testing we […]



Override them both

« 28 August 2007 | 17:03 | rubyonrails | No Comments »

I was trying to override the ‘getter’ part of an attribute accessor on one of my model classes today. After writing some tests and adding the new ‘getter’, I noticed test failures in other areas which should have just been assigning to the accessor.
After a bit of experimentation in the console to see that assignment […]



Asynchronous Email in Rails with ARMailer

« 27 August 2007 | 17:02 | rubyonrails | No Comments »

Back in May I was trying to get asynchronous email going in one of my projects using ARMailer by Eric Hodel. I ran into some issues that we had started to debug and then I got way too busy to follow up on tracking them down. Today I had a few hours to spend on […]



Stubbing the referer method onto TestRequest

« 28 June 2007 | 18:32 | rubyonrails, testing | No Comments »

I have a before_filter that relies on request.referer to set an instance variable (@cancel_link) for use in the views. When trying to test that the instance variable was assigned in my functional tests, I realized that TestRequest doesn’t have the #referer method like CgiRequest does.
fizx on #rubyonrails got me heading in the right direction with […]