Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Avoid render ... and return #327

Open
andyw8 opened this issue Sep 9, 2022 · 4 comments
Open

Suggestion: Avoid render ... and return #327

andyw8 opened this issue Sep 9, 2022 · 4 comments

Comments

@andyw8
Copy link
Contributor

andyw8 commented Sep 9, 2022

Previously this pattern was used in the Rails docs examples but is now discouraged:

https://github.com/rails/rails/pull/45927/files

@andyw8 andyw8 changed the title Avoid render...and return Suggestion: Avoid render ... and return Sep 9, 2022
@pirj
Copy link
Member

pirj commented Sep 9, 2022

It's a controversial topic.
rubocop/ruby-style-guide#730 has been recently merged.
Also related rubocop/ruby-style-guide#785

@mvz
Copy link

mvz commented Dec 29, 2023

While .. and .. is now permitted by the default RuboCop settings, the main problem I see with the render ... and return pattern is that it incorrectly suggests we should not return if the render part somehow fails.

@pirj
Copy link
Member

pirj commented Dec 29, 2023

Should we recommend return render …?

@andyw8
Copy link
Contributor Author

andyw8 commented Dec 29, 2023

I think it's better for the return to be a separate statement. Returning a value would suggest that it's used for something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants