I was googling but couldn’t find any examples of using Devise and Null Object pattern. I just want to check if anyone else sees a potential problem with the code below. Here’s what I came up with:
Nice one, Ben! I don’t currently have any controller specs that would catch possible misbehaviour while existing integration specs and unit tests run fine.
Thats a good improvement! I didn’t think of super before. It is true - not worrying about Devise’s implementation feels much better than using warden’s methods directly. Thanka a lot. And now off to read latest blog post and finish my coffee
@derekprior I have also implemented the null user object using devise, however it broke the user_signed_in? method.
I originally posted this on stack overflow but had no response, but was able to figure out I must have to override this method too.
I have posted what I came up with on there, and was wondering if someone knows a better way or they can re factor it in any kind of way? The link is here
I don’t know how devisse implements user_signed_in? but I’m guessing it’s just checking the current_user is not nil. You’ll probably need to override that to also make sure it’s not a guest. Something like:
def user_signed_in?
super && !current_user.is_a(Guest)
end