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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:55:01+00:00 2026-05-18T21:55:01+00:00

I have a project with several models like students,workers,administrators…. Of course those get different

  • 0

I have a project with several models like students,workers,administrators….
Of course those get different rights on the site.So I was wondering:

Should I log them from different views? so that each one of those views with its forms would handle one (known) model at the time or it would be equally easy to make the three of them in one?.

I tried to make one view but the first problem I had is recognizing which type of user was logging in,therefore it was a problem to know what view should I show next…

  • 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-18T21:55:01+00:00Added an answer on May 18, 2026 at 9:55 pm

    One of the fundamental philosophies behind Rails is DRY–Don’t Repeat Yourself. Following this philosophy, it seems rather redundant to have three separate login screens.

    In the same vein, having students, workers and administrators in separate models seem a bit unpractical. All users will (presumably) have names, emails and passwords–as well as other information. I would only have one model, and call that model what it is–User. Then, I can set up user groups like this:

    class User < ActiveRecord::Base
      belongs_to :user_group
    end
    
    class UserGroup < ActiveRecord::Base
      has_many :users
    end
    
    User.first.user_group # => <UserGroup name: 'Students'>
    User.find(123).user_group # => <UserGroup name: 'Workers'>
    UserGroup.find_by_name('Administrators').users # => [<User ...>, <User ...>, ...]
    

    Suddenly, login is no longer a problem. A user is authenticated as a user, and the application will immediately know what user group they belong to, and can display the appropriate information that way.

    Also, I’d be amiss if I didn’t give a shout-out to Devise. It’s a gem for handling authentication, and would definitely spare you a lot of work and effort if you’re thinking of creating the authentication methods by yourself.

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

Sidebar

Related Questions

I have several ActiveResource model in my project. There was so strange to me
I have been working on a project for a month or so now to
In my ASP.NET MVC 2 (RC) project - I'm using AutoMapper to map between
I am using polymorphic associations to track Comments in my project. All very straight
I have a complex form in Ruby on Rails 2.3.5, here's the structure for
I'd like to: Make commonly required services visible to all classes that need them,
I've decided to develop a database driven web app, but I'm not sure where
I'm trying to figure out how to design a small application more elegantly, and
is it wasteful/bad design to use a vector/list where in most instances it will
I've been using Mercurial for a little while, but mainly for my own use.

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.