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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:50:10+00:00 2026-06-03T20:50:10+00:00

Problem I have a User model, and the Volunteer model that inherits from the

  • 0

Problem

I have a User model, and the Volunteer model that inherits from the User model:

class User < ActiveRecord::Base
end

class Volunteer < User
end

They are both saved on the same table in the database, but have different controllers / routes.

The routes are:

devise_for :users ....
devise_for :volunteers ....

And this works fine and dandy, but the authorization system that I use depends on a current_user helper. And this fails for volunteers because devise creates current_volunteer for the Volunteer model.

What i have tried is to set devise_for :volunteers, :singular => "user", and this creates a current_user that refers to users and volunteers, but the problem now is that the routes for volunteers are messed up.

Question

So my question is, is there any way to have the current_user helper, refer to another model other than user?

  • 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-03T20:50:13+00:00Added an answer on June 3, 2026 at 8:50 pm

    I think this way you allow a user to be signed in as a User and a Voluteer in the same session.

    Once you have a way to deal with that could you not just have

    # in application_controller.rb
    alias_method :devise_current_user, :current_user
    def current_user
      devise_current_user || current_volunteer
    end
    

    in your application_controller.rb

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

Sidebar

Related Questions

I have this code in my user model: class User < ActiveRecord::Base attr_accessible :email,
I have an Account model and a User model: class Account < ActiveRecord::Base has_many
I have a user and post model: class User < ActiveRecord::Base has_many :sent_posts, :class_name
Ive got the following problem. I have a model called user which has a
I have a problem that i cant solve :( I have a user control
My problem is that I have a user that is having a problem displaying
I have a user model that checks to see if a value has changed
I have two models: User and Base. User model: http://pastebin.com/WdLzBkHJ Base model: http://pastebin.com/tQrEUaSu At
I have a User and Company model. There are three possible roles that a
I have an article model and a user model. The user can follow that

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.