Archive for the 'Software' Category

Posted on January 5, 2009 at 5:20 pm

In just about every Rails project I’ve worked on over the last several years we’ve needed track the user who creates and updates database records. The most popular solution seems to be DeLynn Berry’s userstamp plugin and, until recently, that’s what we’ve always chosen to use too. But after fighting incompatibility with newer versions of Rails I decided to write my own plugin. Enter Blame.

Blame automatically userstamps create and update operations if the table has columns named created_by and/or updated_by.

Installation:

ruby script/plugin install git://github.com/infused/blame.git

Blame assumes that you are using restful-authentication and expects User.current_user to return the current user. You can override this behavior by overriding the default userstamp_object method in ActiveRecord::Base or in any of your models. For example, maybe you just want to find the current user bases on the a session variable:

# In environment.rb
class ActiveRecord::Base
  def userstamp_object
    User.find(session[:user_id])
  end
end

Maybe you don’t like the default column names of created_by/updated_by. You can customize the column names globally or for individual models:

# Globally in environment.rb
ActiveRecord::Base.created_userstamp_column = :creator_id

# In a model definition
class Subscription
  self.created_userstamp_column = :creator_id
  self.updated_userstamp_column = :updater_id
end

Automatic userstamping can be turned off by setting record_userstamps:

# Globally in environment.rb
ActiveRecord::Base.record_userstamps = false

# In a model definition
class Subscription
  self.record_userstamps = false
end

Blame also adds a migration helper which will add the created_by and updated_by columns (or your custom column names) to your table:

create_table :widgets do |t|
  t.string :name
  t.timestamps
  t.userstamps
end
Posted on November 3, 2006 at 12:30 pm

Three weeks ago I left the security of my job of the last 8 years to pursue a new career as a freelance consultant/programmer.

I’ve been freelancing part-time for several years and it was always a nice supplement to my income, but I was afraid of going it alone. What if I couldn’t make enough to support my family? What if I’m not good enough? What if I fail and have to go find a job? What will people think of me then?

Earlier this year I came to the realization that there is no reason to fear failing. Would it be the end of the world if I did fail? Hardly. Would I be embarrassed? Probably. But, embarrassed or not, I can always change gears or find another job. I could even give up and just lay around watching TV all day while my wife supports me.

So, now I’m doing what I really love: Developing the best software that I’m able, using Ruby and Ruby on Rails. I also plan to spend more time working on my own software and writing about Ruby and Ruby on Rails. I’m even considering doing some speaking on the subject.

Are you looking for an experienced Ruby or Ruby on Rails developer? Maybe you’re just looking for some mentoring or guidance on a project? Send me an email at keithm at infused.org. I’m always looking for exciting new projects.

Posted on November 17, 2005 at 5:38 pm

Getting ODBC working on OS X is pretty easy, but you’ll have to find the damn drivers first. First grab the newest iODBC SDK from the Software Availability page, and then grab the the Universal Data Access Drivers from the OpenLink download page. Install the SDK first, and then the drivers.

Once you’ve installed both of those packages you will have a new iODBC Administrator program in your Applications/Utilities/ directory. Open it up and add a System DSN just as you would on a Windows machine.

Trackback | General, Software | Comments Off
Posted on October 10, 2005 at 2:52 pm

Can anyone recommend a good automated testing framework for PHP? I’ve been doing all my development in Ruby using TDD and I can hardly stand to work without a test framework now in PHP. I would make the development of Retrospect-GDS test driven as well. Email me if you have any suggestions.

Trackback | Software | Comments Off
Posted on September 29, 2005 at 12:46 pm

Zork

I spent a half hour playing Zork 1 last night. Brought back some good memories.

Trackback | Software | Comments Off