![](/img/trans.png)
[英]`method_missing': undefined local variable or method `authentication_keys' error when installing devise
[英]`method_missing': undefined method `devise_modules'
我正在尝试将模型从RoR应用程序分离为一个宝石。 当我从gem扩展User
模型以添加Devise实例方法时出现错误
我尝试了不同的方法
class SuperClass < ModelsGem::User; end
class SuperClass < ModelsGem::User; end
class User < ActiveModel::Base
他们中没有一个人与devise一起工作。但是,我可以从应用程序中的gem访问User模型的方法,并且除devise之外,其他一切都按预期工作。
你可以做这样的事情
rails g devise:views
rails g devise user
如果我们想添加sth之类的名字和姓氏,则在耙db:migrate之前将其放在db中
t.string :first_name
t.string :last_name
然后rake db:migrate
在用户模型中
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable, :confirmable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
end
希望我能解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.