Open anthony-robin opened 1 year ago
Is there perhaps a more general rule here of not allowing redirect_to
with a string literal?
@andyw8 sometimes it's necessary to redirect_to 'https://some-other-website.com'
True, so perhaps it should only allow a string if it's a full URL (i.e. beginning http
).
This is actually kind of related to https://github.com/rubocop/rubocop-rails/issues/856 but enforcing the opposite.
@andyw8 Is the link #856 wrong?
Yes! But I can't find the one I meant, I think it was about named routes in tests.
Ah, this I think: https://github.com/rubocop/rails-style-guide/issues/328
Is your feature request related to a problem? Please describe.
I often see in projects code such as
redirect_to '/', alert: 'Lorem ipsum'
which is not the most elegant writing. IMO the Rails route helperroot_path
seems a better way to handle it instead of hardcoding/
.Describe the solution you'd like
I would like a cop that throw an offense on this above line and suggest a replacement to
redirect_to root_path, alert: 'Lorem ispum'
:What do you think about this idea ? Thank you :)