In Rails 7.1 it has become possible to annotate partials with the locals they expect Show archive.org snapshot :
# partial _user_name.erb
<%# locals: (user:) %>
<%= user.name %>
# view
<%= render 'user_name' %> <%# this raises an ArgumentError %>
Unfortunately, when some other code in that template raises an ArgumentError
(for example an error in the User#name
method) you will end up with a confusing stacktrace that looks like you have an error in your render
call.
If this happens to you, temporarily remove the annotation to see the correct error.
There is an open issue in rails Show archive.org snapshot .
Posted by Tobias Kraze to makandra dev (2024-06-27 09:55)