rails 3.2.18
devise
pry-rails gem (which installs pry)
pry-doc gem
我启动了rails控制台:
rails c
然后我登录了:
然后我登录了:
[13] pry(main)> ApplicationController.allow_forgery_protection = false
=> false
[14] pry(main)> app.post('/sign_in', {"user"=>{"login"=>"p3.rails.production@gmail.com", "password"=>"Vw#98052"}})
=> 302
302表示我已成功登录,这意味着我可以致电:
[15] pry(main)> app.controller.current_user
但我收到以下回复:
NoMethodError: undefined method `current_user' for #<Devise::FailureApp:0x000000094e33c0>
from (pry):13:in `__pry__'
[16] pry(main)> app.session
给我:
=> {"flash"=>
#<ActionDispatch::Flash::FlashHash:0x00000009509598
@closed=false,
@flashes={:alert=>"You need to sign in or sign up before continuing."},
@now=nil,
@used=#<Set: {}>>}