I've updated my project from Rails 6.1 to Rails 7.0.4 (running ruby 2.7.0)
Everything has been fine except that every form I have on the application now fails with this error:
private method `field_name' called for #<ActionView::Base:0x00000000034008>
I stumbled upon ActionView's changelog which says the following:
Rails 7.0.4 (September 09, 2022)
Guard against
ActionView::Helpers::FormTagHelper#field_name
calls with nilobject_name
arguments. For example:<%= fields do |f| %> <%= f.field_name :body %> <% end %>
Sean Doyle
I'm not really sure to understand what i have to do to fix the problem on the whole project. I already managed to workaround the issue, manually specifying a name parameter for every field of the form like so:
= f.email_field :email, name: 'user[email]', autofocus: true, autocomplete: 'email',
class: 'form-control', placeholder: t('activerecord.attributes.user.email')
But it seems weird to me that i would have to update every single field of every single form of the whole application manually specifying field names as this used to be an automatic behavior. Also that seems not likely to be the solution anyways, form_helpers used to be here to make you're life simpler so that seems really dumb to have to specify every single field_name manually. Especially that everything was working fine in 6.1.
I've been searching around but i really don't find anything else than this changelog message that does not say much on how to properly fix this.
So if anyone have met this situation or have a clue on how to solve this efficiently i woud be more than grateful to have an input!
Solution found !
If by any chance that can be of any help to anyone, in my case, the guilty was a dirty 4yo monkey patch.
I had a DatetimePickerHelper
with the purpose of making available a datetime_picker_tag
method. Which also overrided the field_name
method as a private one.
Just commented that one and boom, everything works like a charm. Just need to figure out what i'm gonna do with those datetime_picker_tag
calls but that's a way easier problem to solve!