-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Action Text) Does't display content in the editor #33
Comments
Thank you for this! |
@Civil21 can you please explain the solution a little bit better. I am not being able to make it work. Thanks! |
Can you explain how this worked @EricRoos |
Hey @Civil21 and the other users: I'm sorry to comment so late on this issue 😓
activeadmin_quill_editor supports only plain text or string fields. That said, I provide a different solution - because from my standpoint - overriding the model's methods is not the best, you could break ActionText functions then. I would use a decorator instead: https://activeadmin.info/11-decorators.html (with draper gem - or you could use any other delegation mechanism) My example:
I'm closing the issue. |
Here it is another alternative version using getter/setter methods (in case you prefer to avoid having a decorator object). A sample model: # app/models/author.rb
class Author < ApplicationRecord
has_rich_text :description
def quill_description
self.description&.body&.html_safe
end
def quill_description=(value)
self.description = value
end
end The admin model configuration: # app/admin/authors.rb
ActiveAdmin.register Author do
permit_params :name, :email, :age, :quill_description
show do
attributes_table do
row :name
row :email
row :age
row :quill_description
end
active_admin_comments
end
form do |f|
f.inputs 'Author' do
f.input :name
f.input :email
f.input :age
f.input :quill_description, as: :quill_editor
end
f.actions
end
end |
Hi @blocknotes |
Hi @blocknotes |
Thank you @BBVishalkumar - I update my last answer 👍 |
Dependencies:
Situation:
If used with Action Text there is a problem. When editing, the editor is empty because it is not possible to read the input content due to
<div class="trix-content">some html content</div>
Of course, this is not a problem of the gem, but since it is recommended to use it when you need to work with Action Text in the active admin, it is worth offering a solution.
My solution (hardcode):
The text was updated successfully, but these errors were encountered: