Reputation: 2584
In rails_admin gem i have a model with some field. In list action is possible to view all field except one field? if i write:
rails_admin do
list do
field :name
end
end
I see only this field, i need the inverse behavior. I have found no solutions
#somethis like this
rails_admin do
list do
field :default , except :created_at
end
end
can you help me?
A possible workaround is list all necessary field, but is not very clean in my opinion
SOLUTION this works for me:
list do
exclude_fields :created_at
end
Upvotes: 4
Views: 7556
Reputation: 1148
"Once in add specified fields mode, you can exclude some specific fields with exclude_fields & exclude_fields_if:"
https://github.com/railsadminteam/rails_admin/wiki/Fields#exclusion
example:
rails_admin do
list do
field :default
end
exclude_fields :created_at
end
Upvotes: 9
Reputation: 35533
This is ruby - use it!
rails_admin do
list do
(column_names - %w{created_at}).each do |col_name|
field col_name.to_sym
end
end
end
Or you can just use the exclude_fields
macro as @flylib has pointed out. ;)
Upvotes: 1