Reputation: 15
My application uses 'rails_admin' and I would like every page within '/admin' to have a custom javascript file.
rails version: 6
EDIT:
My example I want to remove all these comments on each model, when I go to 'add new'.
All of these are <span class = 'help-block'>...</span>
so I thought about using document.getElementsByClassName("help-block").style.visibility = "hidden";
it to solve my problem.
But it did not work.
Upvotes: 0
Views: 762
Reputation: 21
To turn off the 'comments' for the whole model, use the following code in your rails_admin.rb file:
config.model "ModelName" do
edit do
fields do
help false
end
end
end
Upvotes: 0
Reputation: 4619
Rails admin has a way to remove those "comments" for example if you place this code any of your models
rails_admin do
edit do
field :name do
help do
nil
end
end
end
end
Its kind of annoying to do it for every field, but repetition in configuration is one of rails_admin weaknesses
Upvotes: 1
Reputation: 4619
Create this file on your project directory, create the folders if needed:
/app/assets/javascripts/rails_admin/custom/ui.js
Then place this content on the file
//= require_tree .
let yourjavascript = 'whatever you want'
Rails admin will import it this file on every page.
You might need to clear your assets pipeline depending on your configuration
rake tmp:clear
Upvotes: 0