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 7444789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:35:20+00:00 2026-05-29T11:35:20+00:00

Using Rails 3.1.3 with Devise 1.5.3. My app has accounts and users. Each account

  • 0

Using Rails 3.1.3 with Devise 1.5.3. My app has accounts and users. Each account can have multiple users. A user can have one role, “user” or “account_admin”. Devise signup routes to accounts#new. The account and an initial account_admin user are created simultaneously. Got this working as described here (although things have evolved some since then).

An account_admin signs should be able to create additional users in that account. That’s where I’m running into trouble: instead of creating new users, it’s just redirecting to the user_path (users#show) page with the message “You are already signed in.” (user_path is my overridden after_sign_in_path.)

This article asks a similar question. The answer suggests a separate namespace for admins, but since admins are part of my regular app I don’t think that applies.

I’ve defined a complete UsersController. According to the log, GET "/users/new" renders from my “UsersController#new”. However POST "/users" is intercepted by Devise and rendered from “Devise::RegistrationsController#create”.

config/routes.rb

devise_for :users
devise_scope :user do
  get "signup",   :to => "accounts#new"
  get "signin",   :to => "devise/sessions#new"
  get "signout",  :to => "devise/sessions#destroy"
end
resources :users
resources :accounts

app/controllers/users_controller.rb

class UsersController < ApplicationController
  before_filter :authenticate_user!
  load_and_authorize_resource # CanCan
  ...
  def new
    # CanCan:  @user = User.new
  end

  def create
    # CanCan:  @user = User.new(params[:user])
    @user.skip_confirmation! # confirm immediately--don't require email confirmation
    if @user.save
      flash[:success] = "User added and activated."
      redirect_to users_path # list of all users
    else
      render 'new'
    end
  end
  ...
end    

I’ve tried overriding the Devise controller, thinking I could tell it to use my users#create action if the user is already signed in. The log tells me it is using my controller (“Processing by RegistrationsController#create as HTML”), but it doesn’t seem to execute its code. I’ve commented out my custom actions and just left in the logger lines, but I don’t get my logging messages. And in spite of super being commented out, the behavior doesn’t change–it still redirects with “You are already signed in.”

config/routes.rb

devise_for :users, :controllers => {:registrations => "registrations"}

app/controllers/registrations_controller.rb

class RegistrationsController < Devise::RegistrationsController
  def new
    logger.info "Custom RegistrationsController:  new"
    super
  end

  def create
    logger.info "Custom RegistrationsController:  create"
#    super unless user_signed_in?
#    render "users#create"
  end

  def update
    super
  end
end 

What am I missing? How can I let the account_admin user create additional users?

  • 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-29T11:35:22+00:00Added an answer on May 29, 2026 at 11:35 am

    The main issue is that Devise was intercepting the POST "/users" (and a few other routes). Found this workaround to allow my Users controller handle those routes: change the devise_for to skip registrations, then add back in the routes for which Devise normally defines aliases:

    routes.rb

    devise_for :users, :skip => [:registrations]
    devise_scope :user do
      get "signup",   :to => "accounts#new"
      get "signin",   :to => "devise/sessions#new"
      get "signout",  :to => "devise/sessions#destroy"
      get "cancel_user_registration", :to => "devise/registrations#cancel"
      post "user_registration",       :to => "users#create"
      get "new_user_registration",    :to => "accounts#new"
      get "edit_user_registration",   :to => "users#edit"
    end
    resources :users
    resources :accounts
    

    Never figured out why the Devise controller override wasn’t working.

    A user on this thread pointed out the devise_invitable gem which might be an interesting alternative.

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

Sidebar

Related Questions

So I am using Devise for user authentication in my rails app. I have
We have a web app running on Rails, using Devise and OmniAuth for user
I have a class User in Rails using Mongoid and Devise. I can't seem
My Rails 3.1 app has two user models: User and Admin. I'm using Devise.
I am using Rails 3 and Devise to create an app where users arrive
I have a rails application, and I authenticate users to the application using Devise.
I'm using rails 2.3.5 and devise 1.0.6. I'm having users confirm account's with email.
I am using Ruby on Rails and devise for authentication. I have a user(customer)
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

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.