Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.10 KB | None | 0 0
  1. ############ Это, ска, работает ##############
  2. class Product < ActiveRecord::Base
  3.   include PgSearch
  4.  
  5.   pg_search_scope :search_by_spare_and_manufacturer,
  6.     using: {
  7.       tsearch: {prefix: true}
  8.     },
  9.     associated_against: {
  10.       spare: [:name, :article],
  11.       manufacturer: [:name],
  12.     }
  13. end
  14. class Manufacturer < ActiveRecord::Base
  15.   include PgSearch
  16.   multisearchable against: :name
  17. end
  18. class Spare < ActiveRecord::Base
  19.   include PgSearch
  20.   multisearchable against: [:article, :name]
  21. end
  22.  
  23. ### А это нет >< ################
  24. class Order < ActiveRecord::Base
  25.   include PgSearch
  26.   multisearchable against: :order_num  
  27.   pg_search_scope :search_order,
  28.     against: :order_num,
  29.     using: {
  30.       tsearch: {prefix: true}
  31.     },
  32.     associated_against: {
  33.       # natural_person: [:fio, :phone],
  34.       car: [:number, :vin, :year],
  35.       # legal_person: [:name, :phone, :inn, :kpp],
  36.       # mark: [:name],
  37.       # trademark: [:name]
  38.     }  
  39. end
  40. class Car < ActiveRecord::Base
  41.   include PgSearch
  42.   multisearchable against: [:number, :vin, :year]
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement