class WarehouseStock < ActiveRecord::Base belongs_to :product belongs_to :warehouse has_many :categories, :through => :product scope :activos, -> { joins(:product).where( "products.status = 1").order(" products.name") } end