2
votes

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?

2

2 Answers

2
votes

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.

1
votes

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.