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
Rails: I Can't Call a Function in a Module in /Lib - What am I Doing Wrong
How to Check What Is Queued in Activejob Using Rspec
Disable Rvm or Use Ruby Which Was Installed Without Rvm
Postgresql Gem Pg Was Unable to Install
Rails: How to Show User's "Last Seen At" Time
Sorting a Two-Dimensional Array by Second Value
Building a Windows Executable from My Ruby App
App Pushed to Heroku Still Shows Standard Index Page
Namespacing Thor Commands in a Standalone Ruby Executable
How to Structure a Layout Template in Haml
How to Create Database from Schema.Rb Without Initializing Rails
How to Make a Rake Task Run After All Other Tasks? (I.E. a Rake Afterbuild Task)
How to Download a CSV File in Ruby on Rails
Cool Tricks and Expressive Snippets with Ruby Collections/Enumerables