【发布时间】:2012-08-07 12:16:49
【问题描述】:
我是 ROR 的新手。 安装 ActiveAdmin 并用它注册部门模型
部门数据库表如下:
id parent_id name
部门模型:
class Departments < ActiveRecord::Base
attr_accessible :name, :parent_id
belongs_to :parent, :class_name => 'Departments'
validates :name, :presence => true
end
在活动管理员中:
ActiveAdmin.register Departments do
menu :parent => 'Manage'
index do
column :parent_id
column :name
default_actions
end
form do |f|
f.inputs "Departments" do
f.input :parent_id
f.input :name
end
f.buttons
end
end
在索引页面上,它在父列下显示 id 号 我有两个问题
如何显示父名称而不是显示父 ID
添加新部门时,如何显示 Parent 的下拉列表 包含所有部门名称的字段而不是文本字段。
当我单击视图链接时,它会正确显示父名称而不是父 ID
谢谢
【问题讨论】: