module Ecom module Model class WorkProductTemplate < ApplicationRecord validates :code, :name, presence: true, uniqueness: true belongs_to :task_template has_many :product_types scope :filtered_by_template_type, lambda { |id| joins(:task_template).where('ecom_model_task_templates.task_template_type_id = ?', id) .order(:code) } end end end