On Fri, Feb 12, 2021 at 4:34 AM '[email protected]' via sequel-talk <
[email protected]> wrote:
> Hello,
> I'd like to disable a possibility for creating a model directly from STI
> base class. Any idea how to do that properly?
>
> Maybe you're asking why I need that. Imagine that there are some
> validations defined in subclasses but if you create model directly from a
> base class, then those validations are not performed...
>
Something like this should work:
class BaseClass < Sequel::Model
def before_create
raise if instance_of?(BaseClass)
super
end
end
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/CADGZSSfDoGbVF5G7Jd%2BPxhc4H25%2ByU_JQ9N8PAo0kUGL82HnhA%40mail.gmail.com.