We've moved discussions to Discord

Rich Text in Rails Administrate Dashboard Not Working

Martin Curiel
Happy New Year! We are using your template for a project and wanted to add Action Text field to one of my models. I looked at this https://jumpstartrails.com/docs/action_text and it seems straightforward. But I am unable to get things working in the Rails Administrate dashboard. I first tried things by adding body: Field::RichText in the ATTRIBUTE_TYPES object in mymodel_dasbhoard.rb  That didn't work. I then added a new field called content to my model, and added that to mymodel_dasbhoard.rb like so content: Field::RichText. In both cases, I am getting a uninitialized constant Administrate::Field::RichText error .  Any thoughts on this? Maybe it's not possible or recommended to use Rails Administrate and ActionText together and it's best to create a separate form (like you do here in your forum). 
Chris Oliver
I'm using ActionText in JumpstartRails's admin with body: Field::RichText

Make sure you're using my fork of Administrate in the Gemfile as they don't officially support ActionText in Administrate. We will replace Administrate soon with my new admin, Madmin.
Reuben Thiessen
Hi Chris,

I'm getting an error, even with using your fork. Any update on replacing Administrate with Madmin, or ideas why I'd be getting this error:

ActionView::Template::Error (undefined method `body' for "":String):
Chris Oliver
You'll have to share the full stacktrace.

Body should be returning an ActionText::RichText object, not a string. Sounds like maybe you have something misconfigured.

For example, the posts here in the forum use has_rich_text :body and you can see the type:

Post.last.body.class
#=> #<ActionText::RichText>
Reuben Thiessen
Figured it out. Sorry I'm new to Rails 6 (coming from 4.2). Turns out I needed has_rich_text :column_name in the model. My bad. Thanks for your help.
Notifications
You’re not receiving notifications from this thread.