Ruby on Rails
Thursday, January 10, 2019
bypass_sign_in is intended to be used from a controller where you'll have access to things like 'session'
I suggest you start by getting it working in the intended environment before you try to pull it out into a standalone script.
I suggest you start by getting it working in the intended environment before you try to pull it out into a standalone script.
On Thu, 10 Jan 2019 at 22:16, Jason Hsu <jhsu802701@gmail.com> wrote:
--OK, I'm trying out the bypass_sign_in feature. I'm getting the following error:/home/winner/.rbenv/gems/2.6.0/gems/devise-4.5.0/lib/devise/controllers/sign_in_out.rb:112:in `expire_data_after_sign_in!': undefined local variable or method `session' for main:Object (NameError)
I've put the script login.rb in the root directory of the project. The code of login.rb is:require File.expand_path('../config/environment', __FILE__)
require 'devise'
include Devise::Controllers::SignInOut
users = User.all;
num_users = User.count;
n_first = 0;
n_last = num_users - 1;
puts '---------------------------'
puts 'Logging in as a seeded user'
puts ''
puts "Pick a user number from #{n_first} to #{n_last}:"
n_input = gets.chomp().to_i;
@user = users[n_input];
puts @user
bypass_sign_in @user, scope: :userEverything works as expected until the bypass_sign_in. Is there another "require" or "include" statement that I need to add?
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/d85MICj-BJQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/21df3d80-5f5b-4f60-a28a-0bd6d4e5a13d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hobbyist Software is a trading name of Hobbyist Software Limited. Registered office 12 Fraley Rd, Bristol, BS93BS. Registered in England. Company no:7876492
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACTOy%2Boac08H4OHwrF4Q%2B0Je2a%3D%2B4U9m6HsN23RqNhfHgeg7tQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment