0

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.

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Got this error: undefined method `help' for #<RailsAdmin::Config::Sections::Edit:0x0000000008d1a080>
Lol, now it works!. Probably, some sintax error in my code.... Dunno... haha. But thanks :)
0

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

2 Comments

Okay, that's work, but doens't solve my problem has i thought. I gonna edit the question
I added a new solution for your real problem.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.