So one thing I had a WTF? with when I ran into it a few months ago was what routes do when a model name can’t be pluralized. For example, if you have a model named Series. series is both the singular and plural form of the word series, so whereas you’d normally have path methods like book_path and books_path, with Series you get series_path and series_index_path.
If you try to use series_path without an id, you just get an error about the missing argument, and it’s not clear that Rails has generated a series_index_path - which is what you should be using to link to the index.
I’m not sure how realistic or performant it’d be to provide a hint here, but it might be nice to warn the user if it’s detected that they’re trying to access a path method in a specific way when the model isn’t pluralizable.
e.g. series_path(id: 1) wouldn’t trigger the hint, but series_path with no arguments would cause Rails to print something like “You’re using series_path without an id. Series can’t be pluralized, maybe you meant series_index_path?”.
I wouldn’t want to add this check to the generated method because it would incur a runtime cost. But I wonder if we could teach the “did you mean” gem about this case since it handles errors via exceptions.
I cleaned up the PoC and merged it in, so I think we can call this complete? I’ll say this PR was the solution. I feel like many custom exceptions in Rails should have DYM support, but I think we should start opening tickets for each of them on the main GitHub issues page. I also don’t know which exceptions in particular should have DYM support, and I need help finding them.