设计和简单的私人消息
我在 Ruby on Rails 3 应用程序中使用 Devise 。我正在尝试在我的应用程序中实现私人消息传递,并且遇到了这个宝石:
https://github。 com/jongilbraith/simple-private-messages
我(不小心)运行了以下命令。
rails generate simple_private_messages:model User Message
它创建了消息模型。但它更改了我使用 Devise 使用以下命令生成的现有用户模型的一些属性:
rails generate devise User
现在,当我启动 Ruby on Rails 应用程序时,我收到此警告:
[警告]您提供了 devise_for :users 但应用程序中没有定义模型 User
并且我的 Devise 链接已停止工作:
ActionView::Template::Error(#<#:0x1064c9490> 的未定义局部变量或方法“edit_user_registration_path”):
有人可以建议我如何集成两者或在无法同时使用它们的情况下恢复我的更改吗?
I am using Devise in my Ruby on Rails 3 application. I am trying to implement private messaging in my application and I came across this gem:
https://github.com/jongilbraith/simple-private-messages
I (accidentally) ran the following command.
rails generate simple_private_messages:model User Message
It created the Message model. But it changed some properties of my existing User model that I had generated using Devise using the following command:
rails generate devise User
Now, when I start my Ruby on Rails application I get this warning:
[WARNING] You provided devise_for :users but there is no model User defined in your application
And my Devise links have stopped working:
ActionView::Template::Error (undefined local variable or method `edit_user_registration_path' for #<#:0x1064c9490>):
Can someone please suggest how can I integrate the both or revert my changes if it is not possible to use them simultaneously?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我按照以下步骤安装 gem:
将此行 (has_private_messages) 添加到用户模型:
end
编辑routes.rb 文件,这里的顺序很重要,devise_for 应在消息路由之前定义。
如果你想要脚手架:
并记住取消注释(attr_accessor :to):
I've followed these steps to install the gem:
Add this line (has_private_messages) to User Model:
end
Edit the routes.rb file, the order is important here, devise_for should be defined before the messages routes.
If you want the scaffold:
And remember to uncomment this (attr_accessor :to):