12
votes

I had a rails app which was running perfectly with devise 3 and rails 4. I updated rails to 5 and it gave DEPRECATION WARNING: alias_method_chain is deprecated. So i had to change the devise version to 4.0.0.rc1.

Now it seems like the devise is not generating the methods like authenticate_user!, is_admin etc..

I am getting the following error

Before process_action callback :authenticate_user! has not been defined (ArgumentError)

I tried everything including, uninstall devise and install again, then tried to create a separate model from scratch and still the methods are not defined.

Any ideas please ?

3
Are there any updates on this? I'm trying to implement gradual engagement on rails 5 and get similar errors following the wiki.Kevin Brown
I am not sure what errors you get exactly, for my case it was a feature upgrade in rails5 where it can just be fixed by adding an additional parameter, i have mentioned it in the accepted answer. I could find out the issue by inspecting the files by putting a binding.pry debug statement If you are running it from terminal you may get a file path and line number which throws the error, so just don't be afraid to dive into it.Hassan

3 Answers

13
votes

The answer for this is to simply change:

skip_before_action :authenticate_user!

to ---

skip_before_action :authenticate_user!, raise: false

https://github.com/plataformatec/devise/issues/4207 https://github.com/thoughtbot/clearance/issues/621

6
votes

I could identify the issue, in rails 5, there will be an exception if the skipping method is not defined at the time of calling unless we add :unless condition.

1
votes

Until rails5 support lands in devise itself, you can try using this fork:

gem 'devise', github: 'twalpole/devise', branch: 'rails5'