简体   繁体   中英

Customizing active_admin interface

I've a simple question about active admin interface.

In my application, I've a resource added to the active_admin. When I access the resource from active_admin, I get all records for that resource. When I select/access (as a show action) one record it shows details of that instance and all belongs_to associations but I don't know how to get the has_many or has_one association details in the show view?

Any ideas? I appreciate any feedback.

Thanks,
Atarang.

You need to customize your show screen in app/admin/yourresource.rb. You shouldn't need to do anything special otherwise, other than making sure the has_many and belongs_to associations are correct. For example, if you have a category with many items, do this in category.rb:

show :category do
  panel "Category Info" do
    attributes_table_for category, :name, :created_at
  end
  panel "Items in This Category" do
    table_for(category.items) do
      column("Name", :sortable => :name) {|item| item.name }
      column("Created At") {|item| item.created_at }
    end
  end
end

There are more good examples here and elsewhere in the source for the demo project, which for some reason is hard to find from the main site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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