Open ydakuka opened 11 months ago
I agree with the rule, but as with Callbacks Order, I think it's sufficient to give a small example (e.g. two filters) and have a link to the full list (e.g. the post referenced above).
have a link to the full list (e.g. the post referenced above).
I couldn't find this information, specifically the list, in the official Rails guide.
I think it's sufficient to give a small example (e.g. two filters) and have a link to the full list (e.g. the post referenced above).
Done.
We have a related guideline https://github.com/rubocop/rails-style-guide#lexically-scoped-action-filter But it doesn’t tell not to use filters in inherited classes or concerns. I believe that complex inheritance chain is sometimes a necessity.
The consequence on our case is that the order of those filters is hard to predict. And ordering just local ones would just solve part of this disorder.
And ordering just local ones would just solve part of this disorder.
We would have the "correct" order in all controllers. And even with inherited controllers or concerns, the code would still be easier to read. At least it definitely won’t be more difficult.
It is similar to this rule, but for action filters.
ref: https://dev.to/timkrins/an-experiment-with-controller-action-callbacks-in-rails-c3p