Reputation: 763
I'm using Active Storage and Cloudinary to store some images of one of my models, but after add this the Active Storage started to appear in Rails Admin in a navigation tab dedicated to it:
And its models in Dashboard:
I would to like to remove both. I tried these things without sucess:
Starting by trying to declare only the models I want to be present
config.included_models = [User, Notebook, Tag, Category, Part]
But since i'm using attachments in Notebook it complains:
Then I tried to just hide:
config.model 'ActiveStorage' do
list do
visible false
end
navigation do
visible false
end
end
Also with the models directly
config.model 'Attachment' do
list do
visible false
end
navigation do
visible false
end
end
config.model 'Blob' do
list do
visible false
end
navigation do
visible false
end
end
Or maybe it's possible to do something factoring like
ActiveStorage::Base.descendants.each do |imodel|
config.model "#{imodel.name}" do
visible false
end
end
As we can do with ActiveRecord as shown in Creating a Custom Field Factory ?
Upvotes: 0
Views: 1246
Reputation: 423
In rails 6 I used
config.excluded_models = %w[ActiveStorage::Blob ActiveStorage::Attachment ActiveStorage::VariantRecord]
Upvotes: 0
Reputation: 309
In Rails 6 I do the following
RailsAdmin.config do |config|
config.model 'ActiveStorage::Blob' do
visible false
end
config.model 'ActiveStorage::Attachment' do
visible false
end
config.model 'ActiveStorage::VariantRecord' do
visible false
end
end
Upvotes: 0
Reputation: 26
In your rails_admin.rb
add the following:
config.model 'ActiveStorage::Blob' do
visible false
end
since the Blob class comes from ActiveStorage.
The same applies for the Attachment class.
Upvotes: 1
Reputation: 4619
You almost got it, it needs to be
config.model 'Blob' do
visible false
end
Option b) On the model itself blob.rb
class Blob < ApplicationRecord
rails_admin do
visible false
end
end
Upvotes: 1