Skip to content

Fix ActionText::Editor::Tag#render_in to accept kwargs#57356

Merged
guilleiguaran merged 1 commit into
rails:mainfrom
flavorjones:actiontext-editor-tag-render-in-kwargs
May 12, 2026
Merged

Fix ActionText::Editor::Tag#render_in to accept kwargs#57356
guilleiguaran merged 1 commit into
rails:mainfrom
flavorjones:actiontext-editor-tag-render-in-kwargs

Conversation

@flavorjones

@flavorjones flavorjones commented May 12, 2026

Copy link
Copy Markdown
Member

Motivation / Background

Since d24d0b7 (#50623), Action View renders objects responding to #render_in through ActionView::Template::Renderable#render, which calls:

renderable.render_in(context, locals: locals, &@block)

when render_in's arity is not 1.

ActionText::Editor::Tag#render_in(view_context) was not updated to match the new contract. Subclasses that follow the documented adapter pattern render_in(view_context, ...) and call super raise:

ArgumentError: wrong number of arguments (given 2, expected 1)

The bundled TrixEditor::Tag doesn't hit this because it re-implements the body and never calls super. Out-of-tree adapters following the same pattern do.

Detail

This Pull Request widens ActionText::Editor::Tag#render_in to (view_context, ...), so subclasses can call super without caring about Action View's calling convention.

Additional information

Discovered while running Lexxy's CI against Rails main. Lexxy's adapter at lib/action_text/editor/lexxy_editor.rb is the real-world subclass that surfaced this.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Since d24d0b7, Action View calls `render_in(context, locals: ...)`.
Subclasses that call `super` from `render_in(view_context, ...)`
raised ArgumentError. Accept and ignore extra kwargs in the base.

@seanpdoyle seanpdoyle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching and changing this. The latest version of #50623 was opened long before the Action Text adapter changes were proposed and merged.

Are there any additional changes to be made to make the Action View deprecation warning more robust to handle situations like this?

@flavorjones

flavorjones commented May 12, 2026

Copy link
Copy Markdown
Member Author

Are there any additional changes to be made to make the Action View deprecation warning more robust

I don't think so? The main branch right now is emitting deprecation warnings that are addressed by this PR:

DEPRECATION WARNING: Action View support for #render_in without options is deprecated.

Change #render_in to accept keyword arguments.
 (called from block (2 levels) in ActionView::TemplateRenderer#render_template at /home/flavorjones/code/oss/rails/actionview/lib/action_view/renderer/template_renderer.rb:66)

so I think this is just an order-of-merge-operations issue! 😆

@guilleiguaran guilleiguaran merged commit bd81a64 into rails:main May 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants