简体   繁体   English

关联关系属部到的活动管理员覆盖表单页面

[英]active admin overide form page with relation belongs_to

i'm using gem active admin , and i want to override my form page. 我正在使用gem active admin ,并且我想覆盖我的表单页面。 How to showing field from belongs to on my role form if i have relation like this : 如果我有这样的关系,如何显示字段来自属于我的角色表:

model user : 模型用户:

class User < ActiveRecord::Base
  has_one :role
end

model role : 模特角色:

class Role < ActiveRecord::Base
  belongs_to :user
end

how to showing all field on model user in form role in active admin? 如何在活动管理员中以表单角色显示模型用户的所有字段?

i'm found the answer : 我找到了答案:

ActiveAdmin.register Role do
    form do |f|
        f.inputs "Role Details" do
          f.input :user_id
        end

        f.inputs "User Details" do 
          f.input :email, :input_html => { :value => f.object.user.email }      
        end

        f.actions
      end
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM