-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
False positive for ActionControllerFlashBeforeRender
#909
Labels
bug
Something isn't working
Comments
👍 Just encountered the same problem. @thestelz thanks for filing this! |
Hi, I'm not sure it is the same issue, but I have this reduced test case: # frozen_string_literal: true
class ApplicationController < ActionController::Base
def create
@user = User.new(user_params)
if @user.valid?
if SomeService.call(@user)
flash[:success] = t('.flash.success')
redirect_to @user
else
@user.errors.add(:base, 'an error')
render :new, status: :unprocessable_entity
end
else
render :new, status: :unprocessable_entity
end
end
end
|
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Feb 22, 2023
…shBeforeRender` Fixes rubocop#909. This PR fixes a false positive for `Rails/ActionControllerFlashBeforeRender` when using `flash` before `redirect_to` in `if` branch.
9 tasks
Yeah, that is the same problem as the subject. I've opened #937 to resolve the issues. |
koic
added a commit
that referenced
this issue
Feb 22, 2023
…on_controller_flash_before_render [Fix #909] Fix a false positive for `Rails/ActionControllerFlashBeforeRender`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry if this is a duplicate. I was trying to make sure all possible fixes were released before adding this bug report.
We get a
Rails/ActionControllerFlashBeforeRender
error when theif
block does aredirect_to
andreturn
before therender
block (see below for setup).Expected behavior
No error should be triggered for the cop
Rails/ActionControllerFlashBeforeRender
.Actual behavior
It triggers
Rails/ActionControllerFlashBeforeRender
when it shouldn't.Steps to reproduce the problem
I have an admin controller:
I then run
rubocop
and get the following:RuboCop version
The text was updated successfully, but these errors were encountered: