Cameron Bass Cameron Bass - 2 months ago 39
Ruby Question

skip_before_action and Rails 5

I just upgraded to Rails 5 and everything went pretty smoothy but for no apparent reason a method that is called after

skip_before_action
is not allowing rspec to run with this message
Before process_action callback :redirect_heroku_user has not been defined (ArgumentError)
. It is super strange because it works just fine on rails 4. Here is my code:

APPLICATION CONTROLLER



def redirect_heroku_user
redirect_to root_path if heroku_user?
end


CONTROLLER



skip_before_action :redirect_heroku_user, only: :edit


Yeesh this one is strange. Any help would be great thanks!

Answer

According to this thread

Rails 5 will raise the exception

So your solution is to pass raise: false option to skip_before_action:

skip_before_action :redirect_heroku_user, raise: false

See the changelog for more info.

Comments