Hello Programmers&开发人员!!!,当我尝试访问rails console
时,我在DeviseMultipleTokenAuthDevice
遇到问题,然后我收到以下错误:
Loading development environment (Rails 4.2.0)
2.2.4 :001 > DeviseMultipleTokenAuthDevice
NameError: uninitialized constant DeviseMultipleTokenAuthDevice
from (irb):1
from /Users/vishal/.rvm/gems/ruby-2.2.4@devise_demo/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'
from /Users/vishal/.rvm/gems/ruby-2.2.4@devise_demo/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from /Users/vishal/.rvm/gems/ruby-2.2.4@devise_demo/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/vishal/.rvm/gems/ruby-2.2.4@devise_demo/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/vishal/.rvm/gems/ruby-2.2.4@devise_demo/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
2.2.4 :002 >
以下我在项目中使用的宝石用于用户身份验证
gem 'devise'
gem 'devise_multiple_token_auth'
以下是我记录中的表格:
2.2.4 :002 > p ActiveRecord::Base.connection.tables
["schema_migrations", "users", "devise_multiple_token_auth_devices"]
=> ["schema_migrations", "users", "devise_multiple_token_auth_devices"]
2.2.4 :003 >
有关详情,请点击以下链接:
其他必要信息
Ruby版本 2.2.4
Rails版本 4.2.0
数据库 PSQL
答案 0 :(得分:3)
同样的解决方案是,我们要在app / models /
中创建一个名为devise_multiple_token_auth_device.rb
的文件
这里是 devise_multiple_token_auth_device.rb 文件的代码
class DeviseMultipleTokenAuthDevice < ActiveRecord::Base
belongs_to :user
end