jump to navigation

MySQL column defaults ActiveRecord::SchemaDumper February 26, 2008

Posted by John Dewey in ActiveRecord, Database, MySQL, Rails.
add a comment

ActiveRecord::SchemaDumper will use empty strings as the default value for a column marked as NOT NULL, in MySQL versions < 5.0.51.  This behavior recently changeddefaulting to null (nil).  This caused our specs to fail for various reasons.  Something to keep in mind when upgrading.  We had been coding to a MySQL bug.

Run Rake Tasks with Delayed Job February 25, 2008

Posted by John Dewey in Code, Delayed::Job, Example, Rails, Rake.
1 comment so far

We needed to execute a Rake Task in the background, when a particular event occurred in Rails.  We decided to give Delayed::Job aka DJ a shot.  This “decorator” will execute a Rake task, while optionally passing ENV variables to the task.

Execute a Rake task from another task February 18, 2008

Posted by John Dewey in Example, Rake, Ruby.

Executing a Rake task from inside another Rake task is a nice addition to your toolshed.  Passing parameters to the Rake task is even cooler.  ‘Rake::Task[“TaskName”].execute’ and ‘Rake::Task[“TaskName”].invoke‘ to the rescue.  A Rakefile that demonstrates the execution of a task with parameter passing.

Run a Capistrano task on a single server in a given role February 7, 2008

Posted by John Dewey in Capistrano, Code, Command Line, Deployment, Monkey Patch.

There are times I want to run a Capistrano task on a single server, rather than every system in the role. Adding this monkey patch to deploy.rb adds this functionality. To utilize this feature append ‘server=IP_ADDRESS’ to the Cap command. Tasks are defined to run on particular role(s), this feature will target the server inside a particular tasks role. It will not execute a task on an arbitrary server.  CJ Kihlbom filled me in and stated this can be accomplished with `cap deploy HOSTS=IP_ADDRESS`.  See his comments attached to this post.