JP Boily

Founder of Metrics Watch

Jack of all trade SaaS consultant (but mostly code, analytics & marketing)

March 25, 2012

Using Spree and Refinery all together: auth monkey patch

March 25, 2012 - JP -  

Rails engines are awesome, but can also be a pain in the [choose your word]. Mixing Spree and Refinery is a great example of how things can go bad. Both are great products that are easy to extend, but both are using Devise. And then the depency nightmare starts. They both require Devise 2, yay! They still use both Devise, so, what engine will handle logins, logouts, roles, user management, etc? Spree or Refinery? Can you feel the pain? I did feel it...

Solution? Monkey patch!

That was painful, but I did throw a monkey patch to make the auth of Spree and Refinery kinda "work" together. You can use it as-is, but this is not what I recommend. You should inspire your work from it. There are things that are overriden that doesn't need to be. This is certainly not an extension I could be proud of, but it can still be useful to some folks. Feel free to take a look at it, take some parts and make it work just like how you need it. Pull requests are still accepted if you want to make it usable gem.

Hopefully, you won't have too many problems using Refinery 2.0.x and Spree 1.1.x (current master) together besides that problem with Devise. You could even add another mountable engine like Forem! By the way, adding Forem should not be painful at all as it relies on your own User model.