I am a Ruby on Rails developer with over two years of experience, most of which is working remotely. I am a typical Punekar and in my free time I play badminton, workout, go trekking and I like to interact with people. Feel free to slide into my DMs and say Hi! 😄
Until Rails 6,
actiontext’s default attachment HTML tag name was set to action-text-attachment.
An action text’s rich text field when rendered with an attachment would generate the following HTML:
We could change this tag name by parsing the rich_text output
then change the tag name using nokogiri.
Rails 7 added a cleaner and simpler way to do this with the option to set the default attachment HTML tag name using the following configuration option:
If we change the attachment HTML tag name in an existing Rails project,
all the previous attachment tag names will not be updated
hence not being rendered until we update the records with the new configuration in place.
If we try to render such a rich text record,
it will skip rendering the attachment HTML entirely as the tag will be
Restoring the tag name to the previous configuration will render the attachments as before.