如何在Active Admin中隐藏显示字段

时间:2012-03-27 12:36:29

标签: ruby-on-rails-3 activeadmin ruby-on-rails-3.2

我想知道是否有任何方法可以在显示操作中隐藏Active Admin中的字段,或者如果它们是空的,甚至不显示它们?

2 个答案:

答案 0 :(得分:0)

在资源的.rb文件中对其进行排序 -

  show :title => :Company_Name do
panel "COMPANY DETAILS" do
  attributes_table_for company, :Company_Name, :Title, :First_Name, :Surname, :Job_Title,:Direct_Number, :Contact_Email, :Address_1, :Address_2, :Address_3, :City, :Postcode, :Region, :Head_Office, :Showroom, :Trade_Counter, :Factory_Warehouse, :Telephone_Number, :Fax_Number, :Company_Email, :Web_Address, :PVCu_WindowsDoors_Method_1, :PVCu_WindowsDoors_System_1, :PVCu_WindowsDoors_Method_2, :PVCu_WindowsDoors_System_2, :Timber_Sash_Windows_Method, :FPW, :Composite_Doors_Method_1, :Composite_Doors_System_1, :Composite_Doors_Method_2, :Composite_Doors_System_2, :Composite_Doors_Method_3, :Composite_Doors_System_3, :Installer, :Trade, :Domestic, :Commercial, :New_Build 
end
active_admin_comments

答案 1 :(得分:0)

只需在ActiveAdmin文件中添加包含预期属性的show博客,例如关注

 show do
   attributes_table do
     row :id
     row :title
     row :created_at
     row :updated_at        
   end
end