Rails Activeadmin: Showing Table of a Related Resource in the Same View

Rails ActiveAdmin: showing table of a related resource in the same view

To solve this problem, we used partials:

/app/admin/wineries.rb

ActiveAdmin.register Winery do
show title: :name do
render "show", context: self
end
end

app/admin/products.rb

ActiveAdmin.register Product do
belongs_to :winery
index do
render "index", context: self
end
end

/app/views/admin/wineries/_show.builder

context.instance_eval  do
attributes_table do
row :name
row :region
row :primary_contact
end
render "admin/products/index", products: winery.products, context: self
active_admin_comments
end

/app/views/admin/products/_index.builder

context.instance_eval  do
table_for(invoices, :sortable => true, :class => 'index_table') do
column :name
column :vintage
column :varietal
default_actions rescue nil # test for responds_to? does not work.
end
end

Duplicate resource tab with ActiveAdmin

I think you can rename the resource which will allow you to have a duplicate resource tab:

"By default, any references to the resource (menu, routes, buttons, etc) in the interface will use the name of the class. You can rename the resource by using the :as option."

Example:

ActiveAdmin.register Post, :as => "Article"

The resource will then be available as /admin/articles.

http://activeadmin.info/docs/2-resource-customization.html#rename_the_resource

How do I get associated records to show in active admin?

Let me try to guess, you need to display attributes of associations

show do |participant|
attributes_table do
row :id
row :full_name
attributes_table_for participant.volunteer_detail do
row :id
row :volunteer_name
end
end
end

ActiveAdmin - make resource index show 'edit' and 'delete' but not 'view'

ActiveAdmin.register Foobar do

index do
...
column "" do |resource|
links = ''.html_safe
links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'), :class => "member_link delete_link"
links
end
end
end

EDIT

Remove 'Show' link from ActiveAdmin default_actions



Related Topics



Leave a reply



Submit