Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails_admin show all field in list except one field

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
like image 274
user1066183 Avatar asked Sep 13 '25 21:09

user1066183


2 Answers

"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
like image 153
flylib Avatar answered Sep 15 '25 13:09

flylib


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. ;)

like image 27
PinnyM Avatar answered Sep 15 '25 13:09

PinnyM