The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

mr2b (2) [Avatar] Offline
#1
Hi there,

I'm on chapter 7.3 trying to get listing 7.4 to pass the test:

it "cannot access the new action" do
sign_in(:user, user)
get :new
response.should redirect_to(root_path)
flash[:alert].should eql("You must be an admin to do that")
end


I get the following error:

NoMethodError:
undefined method `serialize_into_session' for TrueClass:Class


in this step:

sign_in(:user, user)

I checked that user is not nil (and it isn't!) so the Factory should work well.

It looks like it has something to do with devise, but I can't figure our what's going wrong...
mr2b (2) [Avatar] Offline
#2
Re: Chapter 7.3 serialize_into_session error
hi there again,

I found the mistake myself and it was in the "let" block:

let(:user) do
user = Factory(:user)
user = User.create
user.confirm!
user
end


I forgot the last user so the block return the 'true' from the last statement user.confirm!.

That was why the user was not 'nil' (but 'true') in the sign_up() method...