Replace multiserache by scope search
This commit is contained in:
parent
5b71fff2d6
commit
fc143d26fd
@ -1,6 +1,7 @@
|
|||||||
class PProductRef < ApplicationRecord
|
class PProductRef < ApplicationRecord
|
||||||
belongs_to :p_product
|
|
||||||
|
|
||||||
|
belongs_to :p_product
|
||||||
|
has_one :s_brand, through: :p_product
|
||||||
has_many :p_customer_cats, :through => :p_product
|
has_many :p_customer_cats, :through => :p_product
|
||||||
|
|
||||||
has_many :p_product_features
|
has_many :p_product_features
|
||||||
@ -48,6 +49,17 @@ class PProductRef < ApplicationRecord
|
|||||||
:actions => {:name => "Actions", :reorder => false}
|
:actions => {:name => "Actions", :reorder => false}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include PgSearch::Model
|
||||||
|
pg_search_scope :global_search,
|
||||||
|
against: :cc_name,
|
||||||
|
associated_against: {
|
||||||
|
s_brand: [ :code, :name ],
|
||||||
|
p_product: [:code],
|
||||||
|
p_product_color: [:name, :color]
|
||||||
|
},
|
||||||
|
using: {
|
||||||
|
tsearch: { prefix: true }
|
||||||
|
}
|
||||||
|
|
||||||
def not_imported?
|
def not_imported?
|
||||||
if !self.p_product or !self.p_product.imported
|
if !self.p_product or !self.p_product.imported
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
class CreatePgSearchDocuments < ActiveRecord::Migration[6.0]
|
|
||||||
def up
|
|
||||||
say_with_time("Creating table for pg_search multisearch") do
|
|
||||||
create_table :pg_search_documents do |t|
|
|
||||||
t.text :content
|
|
||||||
t.belongs_to :searchable, polymorphic: true, index: true
|
|
||||||
t.timestamps null: false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
say_with_time("Dropping table for pg_search multisearch") do
|
|
||||||
drop_table :pg_search_documents
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
11
db/schema.rb
11
db/schema.rb
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2021_09_28_122901) do
|
ActiveRecord::Schema.define(version: 2021_09_07_083709) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -2125,15 +2125,6 @@ ActiveRecord::Schema.define(version: 2021_09_28_122901) do
|
|||||||
t.index ["admin_id"], name: "idx_54659_index_partitions_on_admin_id"
|
t.index ["admin_id"], name: "idx_54659_index_partitions_on_admin_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "pg_search_documents", force: :cascade do |t|
|
|
||||||
t.text "content"
|
|
||||||
t.string "searchable_type"
|
|
||||||
t.bigint "searchable_id"
|
|
||||||
t.datetime "created_at", precision: 6, null: false
|
|
||||||
t.datetime "updated_at", precision: 6, null: false
|
|
||||||
t.index ["searchable_type", "searchable_id"], name: "index_pg_search_documents_on_searchable_type_and_searchable_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "portlets", force: :cascade do |t|
|
create_table "portlets", force: :cascade do |t|
|
||||||
t.bigint "block_id"
|
t.bigint "block_id"
|
||||||
t.bigint "content_id"
|
t.bigint "content_id"
|
||||||
|
Reference in New Issue
Block a user