active admin overide form page with relation belongs_to

时间:2015-06-25 19:00:42

标签: ruby-on-rails forms activeadmin

i'm using gem active admin, and i want to override my form page. 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?

1 个答案:

答案 0 :(得分:0)

我找到了答案:

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