STI Devise, remove sign up for admin

Hi,

If I’m using STI with Devise, I have a Admin model inheriting the base
Devise User model. I would like to remove ‘registerable’ from the
Admin model but it inherits registerable from the user model. How
would i disable registration for admins?

bump

On 10 August 2011 17:42, jdkealy [email protected] wrote:

Hi,

If I’m using STI with Devise, I have a Admin model inheriting the base
Devise User model. I would like to remove ‘registerable’ from the
Admin model but it inherits registerable from the user model. How
would i disable registration for admins?

I don’t use Devise but can you not just define a registerable method
in your Admin model?

Colin

A little late to the party, but I just ran into the same issue.

I have my User model set up, and my AdminUser model is inheriting from
the
User model.

Technically, you cannot ‘remove’ the ‘registerable’ module from your
Admin
model without removing it from the User model. We can still set up what
you
want, but we need to go about it a little differently. Basically, the
Admin
model inherits the devise_modules from the User model. Since it is
inheriting this, a new devise_modules variable is not created, but the
original one is pointed to. Since Admin is pointing to the original,
removing anything from that removes it from the original. In order to
accomplish your goal, we are going to duplicate the original so that
Admin
has it’s own copy of devise_modules. The following is how I am handling
this.

class AdminUser < User
self.devise_modules = User.devise_modules.dup
self.devise_modules.delete(:registerable)
end

NOTE: In my situation I wanted to keep the same devise_modules for
Admin,
with the exception of registerable. You could also do something like the
following and simply set the ones you want for Admin.

class AdminUser < User
self.devise_modules = [:database_authenticatable, :rememberable]
end

Hope that gives a little insight and helps anybody else trying to go
about
this.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs