I'm using rails 3.2 and devise 2.1 to create a multi-site CMS
Requirements
- Sites based Basecamp subdomains.
- Have 3 "user" models. 1. Admin(superuser) 2. Authors(each have their own site on subdomain) & Subscribers(read the sites ).
- Authors: registration is normal username/password combo but needs to be approved by admin. their registration form will have subdomain field.
- Subscribers: registration happens by invitation email.
- need separate login & registration forms
Possible Solutions
I have been searching & found few solutions
- 3 Separate models in devise:
$ rails generate devise admin
$ rails generate devise author
$ rails generate devise subscriber
but this gives the following error
$ rails generate devise author
/home/gaurish/.rvm/gems/ruby-1.9.3-p286-perf/gems/devise-2.1.2/lib/devise/rails/routes.rb:443:in 'raise_no_devise_method_error!': Admin does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError)
- STI: single table in the database and for each user type create a model
class Admin < User; end
class Author < User; end
class Subscriber < User; end
Here, I am not sure how this would handle different login/registration workflows. example for subscriber I am planning on using devise_invitable for creating invitations. Admin doesn't need to scoped on basis of subdomains unlike authors & subscribers.
Does this seem complicated? I hope I was able to explain well.