Archive for the 'ruby' Category

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



How to alias a class method in Ruby

« 21 September 2007 | 10:04 | ruby | No Comments »

class << self
alias_method :new_do_thing, :old_do_thing
end

Now I know.