Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7711333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:20:55+00:00 2026-06-01T01:20:55+00:00

So I am using Devise for user authentication in my rails app. I have

  • 0

So I am using Devise for user authentication in my rails app. I have a setup that checks if a user is a member of a league. If he is just a member of 1 league he gets redirected to the user_league page if he has several leagues, he is directed to his/her league index so they can pick what league they want to administer. the ‘after_sign_in_path_for’ method looks like this

def after_sign_in_path_for( resource_or_scope )
    user_leagues = UserLeague.where( :user_id => current_user.id )
    if( user_leagues.count == 1 )
        user_league_url( user_leagues[0].league.id )
    else
        "/users/#{current_user.id}/leagues"
    end
  end

I installed the rails admin gem ‘Active Admin’ which by default uses devise for authentication too. Everytime I try to sign in to Active Admin after installation i get this error:

undefined method `admin_user_url' for #<ActiveAdmin::Devise::SessionsController:0x007f8be2f3e420>

Basically I traced it down to if I remove the function ‘after_sign_in_path_for’ above and restart my rails server the admin works fine (but i cannot log into my app, the way i want to) and if i put it back in and restart my server, I get the error from the admin page again. Whats am I doing wrong? How can i maintain the login flow of my app and still log into active admin?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:20:57+00:00Added an answer on June 1, 2026 at 1:20 am

    Without having used ActiveAdmin, I’d guess you are over-riding the way they are using the redirect internally?

    You could try wrapping the code in a block of current_user, so your code only fires if it’s the user logged in:

    def after_sign_in_path_for(resource_or_scope)
      if current_user?
        user_leagues = UserLeague.where( :user_id => current_user.id )
        if( user_leagues.count == 1 )
          user_league_url( user_leagues[0].league.id )
        else
          "/users/#{current_user.id}/leagues"
        end
      else
        super
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that is using Devise, with a User model, no
I have a Rails 3 app with authentication setup using Devise with the registerable
I have an app that is using devise for authentication. Rails 3 on ruby
I am using Devise and omniauth for authentication in my rails app. I have
I am using devise to manage user authentication in my rails app. Devise is
I have a rails 3.1 project using devise for authentication. I have several user
I've employed devise as the user-authentication gem for my rails web-app. Using this pre-generated
I have created a simple API for a Rails application using token-based-authentication that supports
I just setup a basic rails wiki app. Where user comes in and creates
I'm using Devise for authentication in my Rails app. I'd like to eager load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.