Fri 2008-08-22 ( En pr bl )

Camping sessions not working lately? Well, it’s a problem with Rails 2.1, to be more precise: ActiveRecord 2.1.0.

This took me at least 5 hours, but I finally got it: the latest version of AR does Dirty tracking and partial SQL updates. This means it only saves a new value when it thinks the attribute has changed. Nice, but it bugs Camping. So, here’s the patch:

In your camping/lib/session.rb:

class Session < Base
  serialize :ivars
  def []=(k, v) # :nodoc:
    self.ivars_will_change!  # ActiveRecord 2.1 needs this!
    self.ivars[k] = v 
  end 

With this fix, blokk’s login is also working again. It’s built into 0.992 0.993, so you don’t need to sudo vim your Camping gem:

# with fix for ActiveRecord 2.1
include Camping::Session
class Camping::Models::Session
  def []=(k, v)
    ivars_will_change!
    ivars[k] = v
  end
end

UPDATE: Sorry, it seems my brain is on holiday or something. The first fix didn’t fix anything, I just forgot to test it properly. This one should work.

:note => self: Think before using super.

Say something! / Sag was!

Thanks for this - I am planning to use camping for a web app for a friend and I will probably want active record, though I am thinking of having a go with KirbyBase.
Jonty Davis @ 14:37 on Friday, 2008-09-05

No markup, just plain monospace text. / Kein Markup, nur Normschrift-Klartext.