如何修改rails_admin编辑视图 [英] How to modify rails_admin edit view
本文介绍了如何修改rails_admin编辑视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Contact
类与 User
类相关,如下所示:
I have a Contact
class associated with User
class as follows
class Contact < ActiveRecord::Base
belongs_to :users
end
在我的编辑中显示一个下拉列表,其中包含用户名列表作为组件应与 contact.user_id
绑定的选项。
In my edit I want to show a dropdown with list of user name as options that component should bind with contact.user_id
.
如何
推荐答案
有很多方法可以实现这一目标,下面是一个示例。
There are a number of ways to achieve this, here is one example.
<%= f.select :user_id, Contact.all.collect{|c| [c.user.name, c.user.id]} %>
这将创建一个contact.user.name和contact.user.id数组,并提交选定的联系人
This creates an array of contact.user.name and contact.user.id and submits the selected contact based on the associated user_id to your controller.
您将找到更多信息此处。
这篇关于如何修改rails_admin编辑视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文