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

  • SEARCH
  • Home
  • 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 7511695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:37:48+00:00 2026-05-29T23:37:48+00:00

I have a rails app that is using Devise, with a User model, no

  • 0

I have a rails app that is using Devise, with a User model, no scope.
I’ve also added activeadmin gem in to the app, Active Admin is a gem used for adding an admin dashboard in your application. It uses Devise for logging in users and creates a separate admin_user model for the admins.

I am allowing anonymous, non-logged in users to create shopping carts, creating a session[:cart_id]. If a user logs in I want associate the user with the cart, something like

Cart.find(session[:cart_id]).user = current_user 

I was planning to use Wardens callbacks wardens callbacks to impliment this, something like so :

Warden::Manager.after_set_user :scope => :user do |user, auth, opts|

    Cart.find(session[:cart_id]).user = user 

end

However I get an error if I do that:

<% unless user_signed_in? %> throws an error :admin_user user is not logged in

Anyone got any ideas what is going on?

I’ve looked at related questions, but no help:

How to access session from Warden/Devise after_authentication callback in Rails

Where should warden callbacks be placed in a rails app?

  • 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-05-29T23:37:50+00:00Added an answer on May 29, 2026 at 11:37 pm

    Actually it turned out the issue was solved by setting the default scope in warden,in the devise initializer file.

      # Configure the default scope given to Warden. By default it's the first
      # devise role declared in your routes (usually :user).
      # config.default_scope = :user
    

    Since the active admin routes were added above the devise routes for my user, the adminuser became the default user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails 2.3.x app that implements the act_as_authentic in User model and
I am using Devise in Rails 3, and have a User model in rails
I have a rails app that uses Devise for user auth. In localhost:3000 my
I have a Rails 3 App using devise. I want to create a User/Profile
I have an app that is using devise for authentication. Rails 3 on ruby
I have a rails 3 app that is currently using Devise for authentication. I
I have a Rails app that is storing some user information in a cookie,
I have a Rails 3 app with authentication setup using Devise with the registerable
I am using Devise and omniauth for authentication in my rails app. I have
I have an app that's a simple clone of reddit. Using Devise you can

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.