Monday, July 20, 2015

Revenge of the undefined method `users_url' for #<DeviseCustom::RegistrationsController:

I ran into this problem again when I had a secondary object that I was trying to save along with a Devise user at registration/sign-up. I copied the entire create method so that the secondary object could prevent the Devise user from saving if it had an error. However, when I put that logic in and the user didn't save, I got the title error above.

The problem is that Devise's internal magic gets confused if the user isn't persisted but doesn't have any errors. The solution is to apply an error to resource.errors[:base], where resource is the Devise user.

Wednesday, February 18, 2015

undefined method `user_url' for #<DeviseCustom::RegistrationsController:

I ran into this error when trying to work on a user profile edit page that used Devise.

The error is actually a red herring; what it means is that your update of the user failed or didn't do what you expected, and it's trying to fall back to a default page.

Take a look at your user save methods and callbacks and confirm that the user method is doing what you expect. In my particular case, I had a before_validation callback that set a field on the user that happened to be false. The callback returned that false and mistakenly interpreted it as a failure. So I had to explicitly return true to indicate that the method succeeded.

Friday, February 6, 2015

internal error (got unexpected object kind 'commit')

Trac's Git plugin will sometimes produce error messages on submodules or other obscure Git structures, reporting:
"internal error (got unexpected object kind 'commit')"
when you attempt to browse them. It's suspected this is due to Git submodules.

We fixed this by manually applying this patch to the 0.11 version of the plugin:

I've also added an image of it here, just in case the web site goes away.