Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using redactor with Active Admin

Redactor looks like an awesome rich text editor. I want to use redactor in a specific text area in my Active Admin CMS.

I found this gem which integrates redactor with rails, and so I tried to set it up:

gemfile:

gem 'redactor-rails'

shell:

$ bundle install

config/redactor.yml

lang: 'en'
autoresize: true

config/initializer/active_admin.rb

config.register_stylesheet 'redactor-rails.css'
config.register_javascript 'redactor-rails.js'

the input in my active admin resource config

f.input :contents, input_html: { id: "redactor_here", class: "redactor" }

I've checked:

  • The redactor js/css files are being properly included (in the browser).
  • The redactor class is being set on my textarea.

In the readme for redactor-rails it says that after creating the textarea, you need to call the redactor helper to initialize redactor. However, that redactor helper isn't in the scope of an active admin form.. so where could I call it?

At the moment absolutely nothing is happening in the browser. Any help with this would be greatly appreciated.

like image 573
Alex Coplan Avatar asked Oct 23 '22 15:10

Alex Coplan


1 Answers

Hubble's directions didn't quite work for me, but here's what worked... Follow the directions on the gem's page, then for Active Admin:

In active_admin.js, add

//= require redactor-rails

In active_admin.css.scss, add

@import "redactor-rails";
like image 142
Arcolye Avatar answered Nov 15 '22 06:11

Arcolye