Saturday, July 5, 2008

merb-auth, webrat, and merb_stories

Recently I've been working on getting some stories written for www.recollectr.com and given that I just added in MerbAuth support, I thought now would be a good time to dive back into the previously paused process.

If you're interested in using webrat for merb_stories, you'll want to get the fork that supports merb from here:

http://github.com/gwynm/webrat/tree/master


I'd previously had some stories working with webrat and edge merb, but it looked like the upgrade to using MerbAuth in slice form broke some things. After some investigation I realized that the namespacing that's used in merb-slices was slightly different than what the merb supported fork of webrat was happy with...gwynm's fork adds a cookies= method to Application as follows:


class Application < Merb::Controller
def cookies=(newcookies)
@_cookies = newcookies
end
end


This is fine except with MerbAuth, we have MerbAuth::Application, and as such things were busted a bit. So, doing the same for MerbAuth::Application fixed things right up:


module MerbAuth
class Application < Merb::Controller
def cookies=(newcookies)
@_cookies = newcookies
end
end
end


Thing is, this doesn't exactly belong in MerbAuth as its specific to webrat....and it doesn't exactly belong in webrat as its going to be an issue to any merb-slice. So for the time being I have this in my app code, and things work nicely. I'll probably write a little more and maybe give some examples for general webrat and merb_stories usage, but til then hope this helps anyone else trying all three of these great components.

No comments: