0

I have a Sequel model like this:

class User < Sequel::Model
  include Notificatable

  def validate
    super
    validates_presence [:email]
  end
end

# concerns/notificatable.rb
module Notificatable
    extend ActiveSupport::Concern

    included do
      def validate
        super
        validates_presence [:phone]
      end
    end
end

And here I got a problem: Notificatable validate method overrides the same method in the User model. So there is no :name validations.

How can I fix it? Thanks!

Jack Owels
  • 149
  • 1
  • 9

1 Answers1

1

Why use a concern? Simple ruby module inclusion works for what you want:

class User < Sequel::Model
  include Notificatable

  def validate
    super
    validates_presence [:email]
  end
end

# concerns/notificatable.rb
module Notificatable
  def validate
    super
    validates_presence [:phone]
  end
end
Jeremy Evans
  • 11,959
  • 27
  • 26