Showing selected fields in nested form of rails admin

523 Views Asked by At

I am using Rails admin. I have two models.

    class Company < ActiveRecord::Base
      has_one :admin, class_name: 'User'
      accepts_nested_attributes_for :admin

     rails_admin do
      field :name
      field :admin
     end
   end

   class User < ActiveRecord::Base
     belongs_to :company
   end

My use case is that i want to create company and its admin along with that, i just want to add admin email and send invitation and then after accepting invitation, he/she can fill profile later.

Now issue is that, when i go to rails admin for creating company, i see all the fields of admin which is User, i only want to show admin email, i don't want to save all the fields of admin, only 'email'.

I am not able to find a proper solution for it. Is there any default way to do it?

Edit: I found out that, after writing following in user.rb

 rails_admin do
    field :email
  end

Things worked as expected, but i do not want to disturb user model i want to do it inside parent model that is Company model itself.

Thanks in advance

0

There are 0 best solutions below