1

I have two models namely: Admin and User created using devise in ruby on rails. I want to have a single login page in the root for both user and admin; also user sign up page should be in the same root page while admin will have a separate sign up page. This is similar to a facebook home page with login and sign up at the same page for general user and a separate sign up page for celebrity, band or business.

Please help.

My configurations:

  1. Ruby version - 1.9.3
  2. Rails version - 3.2.13
  3. Devise version - 3.0.0
Sushil
  • 501
  • 7
  • 26
  • 1
    I have managed to solve the issue with the solutions provided [here][1]. [1]: http://stackoverflow.com/questions/7299618/multiple-user-models-with-ruby-on-rails-and-devise-to-have-seperate-registration – Sushil Jul 30 '13 at 16:15

1 Answers1

0

A single User model will be a good option for all user roles.

You can take another model as Role for different types of roles.

Role model

class Role < ActiveRecord::Base 
  has_many :users    
end

User model

class User < ActiveRecord::Base  
  belongs_to :role
end

You can use gem 'cancan' for role based authorization

For view part

On home page You can render different partials for sign in and registration in different sections.

In home.html.erb

<%=render :partial => 'devise/sessions/form' %>
<%= render :partial => 'devise/registrations/form' %>
Debadatt
  • 5,935
  • 4
  • 27
  • 40
  • 1
    Having a single user model would be a bad idea in my case. The admin model has lots of fields to be filled up than in the user model. – Sushil Jul 25 '13 at 17:23