increment! and Mysql::Error: Lock

On a site I’m working on I started noticed a lot of production errors like this: ActiveRecord::StatementInvalid: Mysql::Error: Lock wait timeout exceeded; try restarting transaction: UPDATE users SET counter = 2, updated_at = ‘2010-08-05 20:54:26’ WHERE id = 1234 I traced the error back to a call in the user model: update_attribute(:start_time, DateTime.now) increment!(:counter) </pre>…

acts_as_taggable libraries and the big case problem.

Over the years I’ve had a chance to use the three tagging libraries available for Ruby on Rails: acts-as-taggable-on acts_as_taggable_on_steroids acts_as_taggable I think the original acts as taggable is now defunct. The other libraries are derivatives of that library. In using tags on various sites the problem I always seem to run across is how…

to_json gives TypeError Exception: wrong argument type Hash (expected Data)

Tonight for no apparent reason my tests started turning up this error whenever I tried to call to_json: TypeError Exception: wrong argument type Hash (expected Data) </pre> Specifically, my to_json call looked like this: respond_to do |format| format.js { render :json => @states.to_json(:only => [:id, :name]) } end </pre> In the debugger .to_json worked but…

Interesting testing issue with Rails 2.3.3

I’m not sure if this applies to all the versions of Rails, but right now I’m using the latest 2.3.3. I’m using shoulda to do testing and my code looks like this: context “GET show” do setup do @feed = Factory(:feed) get :show, :id => @feed.to_param end should_not_set_the_flash should_respond_with :success should_render_template :show end </pre> The…