In order to only show relevant information to my users I want to disable the whole panel when all fields inside that panel are empty.
Currently I do this hacky method to get to this result:
if resource.phone.present? or resource.fax.present? or resource.email.present? or resource.website.present? panel I18n.t('contact_details') do attributes_table_for resource do row :phone if resource.phone.present? row :fax if resource.fax.present? row :email if resource.email.present? row :website if resource.website.present? end end end
So I need to check all fields in order to know if I display the panel. Then once I display the panel I need to check all the fields again in order to display the given row or not.
Now the user sees only what is relevant but my admin code is cluttered and no longer as maintainable.