How to sign in a user using Devise from a Rails console? -
after loading rails console, how should sign in user?
devise provides test helper can used in tests , i've tried use in console:
>> include devise::testhelpers >> helper.sign_in(user.first)
but get:
nomethoderror: undefined method `env' nil:nilclass
anyway, use real devise helper , not test helper. there way achieve this?
here's 1 way able it:
>> applicationcontroller.allow_forgery_protection = false >> app.post('/sign_in', {"user"=>{"login"=>"login", "password"=>"password"}})
then can do:
>> app.get '/some_other_path_that_only_works_if_logged_in' >> pp app.response.body
Comments
Post a Comment