administrate
administrate copied to clipboard
Guidance for Action Text custom field gem
I wanted to create an open source custom field https://github.com/migu0/administrate-field-action_text based on thoughtbot's instructions here.
I can successfully load the field but the Trix editor doesn't show. Can you help me find out how to get this working? I might have some Trix or Actiontext Javascript or CSS missing? Where should I best load it?
Here's a test app to replicate the error: https://github.com/migu0/testapp
Thank you!
Hello @migu0 - I was having a look at this, but it looks like you have yanked the gem? If you could update the repo so that it's buildable, I'll try have another look.
One initial question is: is all the JS and CSS for Trix, etc loading? In other words: do you see any 404s for them in your Network tab?
Hi @pablobm thank you for following up on this. I gave up on it and removed Administrate from the project to make it work as I'm not very good with JS. If it helps I can re upload the gem or you could get it directly from Github in case you think it's worthwhile pursuing. I don't see any 404s but the below
.
Right. So those import lines for Trix and ActionText, did you add them yourself? As the error shows, it appears not to be transpiled, and the browser doesn't understand it.
This is a topic that confuses me too, and I need to research better how to do it properly across different versions of Rails and its ever-changing ways of handling assets. If it helps, currently I have a personal app where I load the assets as follows:
# config/initializers/administrate.rb
Administrate::Engine.add_stylesheet("admin/application")
// package.json, dependencies
// Not sure if this one is actually relevant, actually
"@rails/webpacker": "^5.3.0",
# config/initializers/assets.rb
Rails.application.config.assets.precompile += ["admin/application.css"]
# app/assets/stylesheets/admin/application.css
/*
*= require_tree .
*= require_self
*/
Then my CSS is at app/assets/stylesheets/admin/. Your problem is with JS instead, but the solution might be similar.
If you have the chance to try, please let me know how it went.
Hi Pablo, I had to give up on this due to time constraints and lack of understanding of the JS pipeline in Rails. I recommend we close this and I'll move the repo on my side to private. Thank you
No worries. Thank you for coming back to me :slightly_smiling_face: