0

I'm using multiple rich text fields in my form on a rails 6 app, but only the first field is storing in the database the remaining fields are not showing on the db at all .

module.rb
has_rich_text :content
has_rich_text :references
has_rich_text :footnotes

_form.html.erb
f.rich_text_area :content
f.rich_text_area :references
f.rich_text_area :footnotes

controller.rb
params.require... :content, :references, :footnotes...

Charlie
  • 236
  • 2
  • 13

2 Answers2

2

You need to override the input's id attribute, like so:

<%= form.rich_text_area :footnotes, class: "", id: "modelname_#{form_model.id}_footnotes" %>, where the id is an arbitrary string that must be unique, like "chapter_1_footnotes".

aidan
  • 1,627
  • 17
  • 27
0

Yes this can work but make sure the names of your has_rich_text :attribute_name doesn't match any of the attribute names on your model.

Dan Engel
  • 75
  • 1
  • 10