Writing data-targets when your controller name is long and in a folder?

I have a controller named step-activities--form-button. Here’s how it’s used:

<%= form_for @model, data: { controller: "step-activities--form-button" } do | f | %>
<% end %>

How do I add a data target to this form? Ruby/Rails doesn’t like it when I write { step-activities--form-button-target: "example" }. And I can’t seem to find any naming convention guidance for this case. Help?

You could replace the dashes(-) with underscores(_) rails’s tag helpers would convert it into dashes themselves. So, in your case it would be

<%= form_for @model, data: { controller: "step-activities--form-button", step_activities__form_button_target: "example" } do | f | %>
<% end %>

Or, you could use string symbols, i.e wrapping the hash keys inside a string literal

"step-activities--form-button-target": "example"

Tho. You would most likely get critic bombed.