2

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?

V_H
  • 1,793
  • 3
  • 34
  • 59

2 Answers2

2

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.

Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145
1

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.

Oss
  • 4,232
  • 2
  • 20
  • 35