V_H
V_H

Reputation: 1793

Single Table Inheritance in Rails and Devise options

If I have a main User model that has the standard devise line in it, and a Single Table Inheritance subclass model, how can I override my default devise options for the subclass? For example, the main user class has "confirmable", but I don't want that on the STI Subclass?

Upvotes: 2

Views: 177

Answers (2)

Oss
Oss

Reputation: 4320

As Andrey said it is not possible.

As for the confirmable part. You can override your registrations controller for that model and after you build you subclass just call skip_confirmation! which assigns a value in the confirmed_at? column.

user = UserSub.new(user_sub_params)
user.skip_confirmation!

As for the other devise options, I am sure there is a way around. Edit your question to ask about more options if you need and I will edit the answer.

Upvotes: 1

Andrey Deineko
Andrey Deineko

Reputation: 52377

I think it is not possible. Why? Because confirmable (for example) operates on the db level, involving column(s) like confirmed_at? and so on.

Since you have only one database table, you can not establish it in a way, that it contain a column for one submodel, and does not for another - it is one table.

And, after all, it does not hurt this much (if hurts at all) to care about it.

Upvotes: 2

Related Questions