before_action - performing an action to prevent

You have not told us what the problem is that you are trying to fix, as far as I can see.

Colin