Sha256: 29862dd33c000b73caaf556d9215276e4e6227e83025d9457ab309f9b8330d50

Contents?: true

Size: 398 Bytes

Versions: 5

Compression:

Stored size: 398 Bytes

Contents

class Client < ActiveRecord::Base
  has_many :orders

  # search
  searchable_by_simple_filter

  scope :bought_product, lambda {  |product_id| where_bought_product(product_id) }

  def self.where_bought_product(product_id)
    v = (product_id.to_i rescue 0)
    if v>0
      where(:order_id => DeviceModel.select("id").where(:device_brand_id => id))
    else
      where("1=1")
    end
  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_search_filter-0.2.1 test/dummy/app/models/client.rb
simple_search_filter-0.1.1 test/dummy/app/models/client.rb
simple_search_filter-0.1.0 test/dummy/app/models/client.rb
simple_search_filter-0.0.31 test/dummy/app/models/client.rb
simple_search_filter-0.0.30 test/dummy/app/models/client.rb