未定义的方法“devise_for”在轨道上
安装设备并创建用户模型后。我rake db:migrate
,然后rake paths
。然后我得到一个错误“undefined method `devise_for' for #”。什么可能导致此错误?
After I install devise and create a user model. I rake db:migrate
and then I rake routes
. I then get a error with "undefined method `devise_for' for #". What could be causing this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请记住在安装和配置设备后重新启动 Rails 服务器。
Remember to restart your rails server after installing and configuring devise.
如果您在 Gemfile 中指定了 Devise gem,只需确保您的 paths.rb 文件中包含以下内容:
另外,这里有一个技巧可以确保 Devise 正确映射,运行:rails c, (Rails 应用程序控制台)您的应用程序的文件夹,然后输入以下命令行:
您应该看到:
干杯!
If you have the Devise gem specified in the Gemfile, just make sure you have the following in your routes.rb file:
Also, here's a trick to make sure Devise is mapped properly, run: rails c, (the Rails app console) in your app's folder and then the following command line:
You should see:
Cheers!
老实说,我建议您关注这两个 Railscast(第 209 集 和 第 210 集)。第一个是安装 Devise 的简单且非常容易的演练,第二个是关于自定义它以适合您的应用程序。
我看过这两集,它们对我的 Devise 帮助很大,特别是在定制方面。
最好的选择是从头开始 - 您将学到很多东西,并且 Devise 已完全安装并正常运行。
希望这有帮助!祝你好运。
Honestly, I would recommend following these two Railscasts (Episode 209 and Episode 210). The first is a simple and very easy walkthrough for installing Devise and the second is about customizing it to fit your application.
I've watched both episodes and they drastically helped me with Devise, particularly with the customization.
Your best bet is to start from scratch - you'll learn a heck of a lot and have Devise fully installed and functional.
Hope this helps! Good luck.
您可能需要进行
捆绑安装
You may need to do a
bundle install