Rails / Devise:立即创建用户和父组织
使用设计。
模型:
User belongs_to Organization
Organization has_many Users
在注册过程中,我还想创建用户的父组织。因此,表单有两部分:1)组织信息,2)基本用户信息(电子邮件/密码)
我已经搜索了很多 Devise 和嵌套资源,但他们通常谈论模型关系是另一个方向(用户 has_many)。
有什么想法吗?
提前致谢!
Using Devise.
Models:
User belongs_to Organization
Organization has_many Users
During signup, I want to create the user's parent organization as well. So two pieces to the form: 1) organization info, and 2) basic user info (email/password)
I've done a bunch of searching for Devise and nested resources, but they usually talk about the model relationship being the other direction (User has_many).
Any ideas?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否已经知道用户可能属于的组织?
在这种情况下,只需在注册时下拉菜单并在保存时插入组织的 ID。
否则,可能会发生的情况是,无论如何,由于拼写错误等原因,您基本上最终都会得到 1:1 的组织,除非您根据他们输入的名称进行猜测。该组织是否有任何与之相关的安全措施?如果这是一个公共场所,那似乎有点危险,因为人们可能会在不应该去的地方露营。
也就是说:
或者类似的东西。
Do you already know the organisations that the user could belong to?
In which case just have a drop down when they register and insert the ID of the organisation on save.
Otherwise, what will probably happen is that you basically end up with a 1:1 with organisation anyway given typos and so on, unless you are guessing based on the name they input. Does the organisation have any kind of security associated with it? If this is a public site it seems a little dangerous because people could camp in places they're not supposed to be.
That said:
or something like that.