Shortcut for customizing ActiveAdmin columns
I've been working with ActiveAdmin lately in Rails, and sometimes need to customize the index view of a model without rewriting all the attributes that I don't want to change.
I want to exclude a few columns simply without writing a bunch of ActiveAdmin dsl.
The code below does this simply and is easily embeddable into the ActiveAdmin dsl.
Colleague is my model name below. Replace it with yours.
The code below goes in the /app/admin/colleague.rb
ActiveAdmin.register Colleague do
index do
excluded = ["bio", "phone", "created_at"]
(Colleague.column_names - excluded).each do |c|
column c.to_sym
end
end
end
Written by Jordan Trevino
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#