diff --git a/.circleci/config.yml b/.circleci/config.yml index d9f3e484..29330f8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ jobs: working_directory: ~/slovensko-digital/navody.slovensko.digital docker: - - image: circleci/ruby:2.6.6-node-browsers + - image: circleci/ruby:2.7.1-node-browsers environment: CC_TEST_REPORTER_ID: 17d259e00bbff5b020b7f1a6abb6736e0f65b9a517afdcbaeaa79e919730835f PGHOST: localhost @@ -28,6 +28,7 @@ jobs: - run: gem update --system - run: gem install bundler - run: bundle config set deployment true + - run: bundle config set path vendor/bundle - run: bundle install - save_cache: { key: '{{ checksum "Gemfile.lock" }}', paths: [vendor/bundle] } - restore_cache: { keys: ['{{ checksum "yarn.lock" }}'] } diff --git a/.ruby-version b/.ruby-version index 338a5b5d..860487ca 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.6 +2.7.1 diff --git a/Gemfile b/Gemfile index 3e9edffb..2eccee2c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,13 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.6.6' +ruby '2.7.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0' gem 'rails-i18n' # Use postgresql as the database for Active Record -gem 'pg', '>= 0.18' +gem 'pg' # Use Puma as the app server gem 'puma' # Use SCSS for stylesheets @@ -37,7 +37,7 @@ gem 'jbuilder' gem 'que', github: 'chanks/que' # https://github.com/chanks/que/issues/253 # Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.1.0', require: false +gem 'bootsnap', require: false gem 'omniauth' gem 'omniauth-google-oauth2' @@ -67,7 +67,7 @@ group :development, :test do gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'dotenv-rails' gem 'factory_bot_rails' - gem 'rspec-rails', '~> 4.0.0.beta2' + gem 'rspec-rails', '4.0.0.beta4' gem 'rspec_junit_formatter' gem 'faker' end @@ -85,11 +85,11 @@ end group :test do # Adds support for Capybara system testing and selenium driver - gem 'capybara', '>= 2.15' + gem 'capybara' gem 'show_me_the_cookies' gem 'selenium-webdriver' - gem 'webdrivers', '~> 3.0' - gem 'simplecov' + gem 'webdrivers' + gem 'simplecov', '< 0.18' # https://github.com/codeclimate/test-reporter/issues/413 end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index 0328faa9..3f2bc4af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,90 +1,90 @@ GIT remote: https://github.com/chanks/que.git - revision: 5ddddd5ebac6153d7a683ef08c86bced8e03fb51 + revision: da0fd08d9d33aa469f172d07f45dc398c2244108 specs: - que (1.0.0.beta3) + que (1.0.0.beta4) GEM remote: https://rubygems.org/ specs: - actioncable (6.0.0) - actionpack (= 6.0.0) + actioncable (6.0.3.3) + actionpack (= 6.0.3.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) + actionmailbox (6.0.3.3) + actionpack (= 6.0.3.3) + activejob (= 6.0.3.3) + activerecord (= 6.0.3.3) + activestorage (= 6.0.3.3) + activesupport (= 6.0.3.3) mail (>= 2.7.1) - actionmailer (6.0.0) - actionpack (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) + actionmailer (6.0.3.3) + actionpack (= 6.0.3.3) + actionview (= 6.0.3.3) + activejob (= 6.0.3.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.0) - actionview (= 6.0.0) - activesupport (= 6.0.0) - rack (~> 2.0) + actionpack (6.0.3.3) + actionview (= 6.0.3.3) + activesupport (= 6.0.3.3) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.0) - actionpack (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) + actiontext (6.0.3.3) + actionpack (= 6.0.3.3) + activerecord (= 6.0.3.3) + activestorage (= 6.0.3.3) + activesupport (= 6.0.3.3) nokogiri (>= 1.8.5) - actionview (6.0.0) - activesupport (= 6.0.0) + actionview (6.0.3.3) + activesupport (= 6.0.3.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.0) - activesupport (= 6.0.0) + activejob (6.0.3.3) + activesupport (= 6.0.3.3) globalid (>= 0.3.6) - activemodel (6.0.0) - activesupport (= 6.0.0) - activerecord (6.0.0) - activemodel (= 6.0.0) - activesupport (= 6.0.0) - activestorage (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) + activemodel (6.0.3.3) + activesupport (= 6.0.3.3) + activerecord (6.0.3.3) + activemodel (= 6.0.3.3) + activesupport (= 6.0.3.3) + activestorage (6.0.3.3) + actionpack (= 6.0.3.3) + activejob (= 6.0.3.3) + activerecord (= 6.0.3.3) marcel (~> 0.3.1) - activesupport (6.0.0) + activesupport (6.0.3.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - zeitwerk (~> 2.1, >= 2.1.8) + zeitwerk (~> 2.2, >= 2.2.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - aws-eventstream (1.0.3) - aws-partitions (1.212.0) - aws-sdk-core (3.67.0) - aws-eventstream (~> 1.0, >= 1.0.2) - aws-partitions (~> 1.0) + aws-eventstream (1.1.0) + aws-partitions (1.373.0) + aws-sdk-core (3.107.0) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-rails (2.1.0) + aws-sdk-rails (3.1.0) aws-sdk-ses (~> 1) - railties (>= 3) - aws-sdk-ses (1.26.0) - aws-sdk-core (~> 3, >= 3.61.1) + railties (>= 5.2.0) + aws-sdk-ses (1.35.0) + aws-sdk-core (~> 3, >= 3.99.0) aws-sigv4 (~> 1.1) - aws-sigv4 (1.1.0) - aws-eventstream (~> 1.0, >= 1.0.2) + aws-sigv4 (1.2.2) + aws-eventstream (~> 1, >= 1.0.2) bindex (0.8.1) - bootsnap (1.4.5) + bootsnap (1.4.8) msgpack (~> 1.0) builder (3.2.4) - byebug (11.0.1) - capybara (3.29.0) + byebug (11.1.3) + capybara (3.33.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -92,22 +92,21 @@ GEM rack-test (>= 0.6.3) regexp_parser (~> 1.5) xpath (~> 3.2) - childprocess (2.0.0) - rake (< 13.0) + childprocess (3.0.0) clockwork (2.0.4) activesupport tzinfo - coderay (1.1.2) - concurrent-ruby (1.1.6) + coderay (1.1.3) + concurrent-ruby (1.1.7) crass (1.0.6) - css_parser (1.7.0) + css_parser (1.7.1) addressable - diff-lcs (1.3) + diff-lcs (1.4.4) docile (1.3.2) - dotenv (2.7.5) - dotenv-rails (2.7.5) - dotenv (= 2.7.5) - railties (>= 3.2, < 6.1) + dotenv (2.7.6) + dotenv-rails (2.7.6) + dotenv (= 2.7.6) + railties (>= 3.2) erubi (1.9.0) ethon (0.12.0) ffi (>= 1.3.0) @@ -116,32 +115,32 @@ GEM rails (>= 4.2.0) responders execjs (2.7.0) - factory_bot (5.0.2) - activesupport (>= 4.2.0) - factory_bot_rails (5.0.2) - factory_bot (~> 5.0.2) - railties (>= 4.2.0) - faker (2.3.0) - i18n (~> 1.6.0) - faraday (0.15.4) + factory_bot (6.1.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.1.0) + factory_bot (~> 6.1.0) + railties (>= 5.0.0) + faker (2.14.0) + i18n (>= 1.6, < 2) + faraday (1.0.1) multipart-post (>= 1.2, < 3) - ffi (1.11.1) + ffi (1.13.1) globalid (0.4.2) activesupport (>= 4.2.0) - hashie (3.6.0) + hashie (4.1.0) hirb (0.7.3) htmlentities (4.3.4) - i18n (1.6.0) + i18n (1.8.5) concurrent-ruby (~> 1.0) - jbuilder (2.9.1) - activesupport (>= 4.2.0) + jbuilder (2.10.1) + activesupport (>= 5.0.0) jmespath (1.4.0) - jquery-rails (4.3.5) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.3.1) - jwt (2.2.1) + jwt (2.2.2) kaminari (1.2.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.1) @@ -154,92 +153,91 @@ GEM activerecord kaminari-core (= 1.2.1) kaminari-core (1.2.1) - launchy (2.4.3) - addressable (~> 2.3) + launchy (2.5.0) + addressable (~> 2.7) letter_opener (1.7.0) launchy (~> 2.2) - letter_opener_web (1.3.4) + letter_opener_web (1.4.0) actionmailer (>= 3.2) letter_opener (~> 1.0) railties (>= 3.2) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.5.0) + listen (3.2.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.7.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - method_source (0.9.2) - mimemagic (0.3.3) + method_source (1.0.0) + mimemagic (0.3.5) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.14.1) - msgpack (1.3.1) - multi_json (1.13.1) + minitest (5.14.2) + msgpack (1.3.3) + multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) - nio4r (2.5.2) - nokogiri (1.10.8) + nio4r (2.5.4) + nokogiri (1.10.10) mini_portile2 (~> 2.4.0) - oauth2 (1.4.1) - faraday (>= 0.8, < 0.16.0) + oauth2 (1.4.4) + faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - oj (3.9.1) - omniauth (1.9.0) - hashie (>= 3.4.6, < 3.7.0) + oj (3.10.14) + omniauth (1.9.1) + hashie (>= 3.4.6) rack (>= 1.6.2, < 3) omniauth-google-oauth2 (0.8.0) jwt (>= 2.0) omniauth (>= 1.1.1) omniauth-oauth2 (>= 1.6) - omniauth-oauth2 (1.6.0) - oauth2 (~> 1.1) + omniauth-oauth2 (1.7.0) + oauth2 (~> 1.4) omniauth (~> 1.9) - pg (1.1.4) - pg_search (2.3.0) - activerecord (>= 4.2) - activesupport (>= 4.2) - premailer (1.11.1) + pg (1.2.3) + pg_search (2.3.2) + activerecord (>= 5.2) + activesupport (>= 5.2) + premailer (1.13.1) addressable css_parser (>= 1.6.0) htmlentities (>= 4.0.0) - premailer-rails (1.10.3) + premailer-rails (1.11.1) actionmailer (>= 3) premailer (~> 1.7, >= 1.7.9) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) pry-rails (0.3.9) pry (>= 0.10.4) - public_suffix (4.0.1) - puma (4.3.5) + public_suffix (4.0.6) + puma (5.0.0) nio4r (~> 2.0) rack (2.2.3) rack-proxy (0.6.5) rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.0.0) - actioncable (= 6.0.0) - actionmailbox (= 6.0.0) - actionmailer (= 6.0.0) - actionpack (= 6.0.0) - actiontext (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) - activemodel (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) + rails (6.0.3.3) + actioncable (= 6.0.3.3) + actionmailbox (= 6.0.3.3) + actionmailer (= 6.0.3.3) + actionpack (= 6.0.3.3) + actiontext (= 6.0.3.3) + actionview (= 6.0.3.3) + activejob (= 6.0.3.3) + activemodel (= 6.0.3.3) + activerecord (= 6.0.3.3) + activestorage (= 6.0.3.3) + activesupport (= 6.0.3.3) bundler (>= 1.3.0) - railties (= 6.0.0) + railties (= 6.0.3.3) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -249,47 +247,46 @@ GEM rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.0.0) - actionpack (= 6.0.0) - activesupport (= 6.0.0) + railties (6.0.3.3) + actionpack (= 6.0.3.3) + activesupport (= 6.0.3.3) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) - rake (12.3.3) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) ffi (~> 1.0) recaptcha (5.5.0) json - regexp_parser (1.6.0) - responders (3.0.0) + regexp_parser (1.7.1) + responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) - rollbar (2.22.1) - rspec-core (3.8.2) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.4) + rollbar (3.0.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.1) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (4.0.0.beta2) + rspec-support (~> 3.9.0) + rspec-rails (4.0.0.beta4) actionpack (>= 4.2) activesupport (>= 4.2) railties (>= 4.2) - rspec-core (~> 3.8) - rspec-expectations (~> 3.8) - rspec-mocks (~> 3.8) - rspec-support (~> 3.8) - rspec-support (3.8.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) - ruby_dep (1.5.0) - rubyzip (1.3.0) + rubyzip (2.3.0) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) - sassc (2.2.0) + sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) @@ -297,72 +294,74 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (3.142.4) - childprocess (>= 0.5, < 3.0) - rubyzip (~> 1.2, >= 1.2.2) - show_me_the_cookies (5.0.0) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + semantic_range (2.3.0) + show_me_the_cookies (5.0.1) capybara (>= 2, < 4) - sib-api-v3-sdk (5.2.5) + sib-api-v3-sdk (5.5.0) json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) - simplecov (0.17.0) + simplecov (0.17.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sitemap_generator (6.0.2) + sitemap_generator (6.1.2) builder (~> 3.0) - spring (2.1.0) + spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (3.7.2) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.20.3) + thor (1.0.1) thread_safe (0.3.6) - tilt (2.0.9) - turbolinks (5.2.0) + tilt (2.0.10) + turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - typhoeus (1.3.1) + typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (1.2.7) thread_safe (~> 0.1) - uglifier (4.1.20) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) - web-console (4.0.1) + web-console (4.0.4) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (3.9.4) + webdrivers (4.4.1) nokogiri (~> 1.6) - rubyzip (~> 1.0) - selenium-webdriver (~> 3.0) - webpacker (4.0.7) - activesupport (>= 4.2) + rubyzip (>= 1.3.0) + selenium-webdriver (>= 3.0, < 4.0) + webpacker (5.2.1) + activesupport (>= 5.2) rack-proxy (>= 0.6.1) - railties (>= 4.2) - websocket-driver (0.7.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) + websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.3.0) + zeitwerk (2.4.0) PLATFORMS ruby DEPENDENCIES aws-sdk-rails - bootsnap (>= 1.1.0) + bootsnap byebug - capybara (>= 2.15) + capybara clockwork dotenv-rails exception_handler @@ -378,7 +377,7 @@ DEPENDENCIES oj omniauth omniauth-google-oauth2 - pg (>= 0.18) + pg pg_search premailer-rails pry-rails @@ -388,13 +387,13 @@ DEPENDENCIES rails-i18n recaptcha rollbar - rspec-rails (~> 4.0.0.beta2) + rspec-rails (= 4.0.0.beta4) rspec_junit_formatter sass-rails selenium-webdriver show_me_the_cookies sib-api-v3-sdk - simplecov + simplecov (< 0.18) sitemap_generator spring spring-watcher-listen @@ -403,11 +402,11 @@ DEPENDENCIES uglifier wdm (~> 0.1.0) web-console - webdrivers (~> 3.0) + webdrivers webpacker RUBY VERSION - ruby 2.6.6p146 + ruby 2.7.1p83 BUNDLED WITH 2.1.4 diff --git a/app/controllers/admin/documents_controller.rb b/app/controllers/admin/documents_controller.rb index 73802e39..d795af67 100644 --- a/app/controllers/admin/documents_controller.rb +++ b/app/controllers/admin/documents_controller.rb @@ -3,7 +3,7 @@ class Admin::DocumentsController < Admin::AdminController # GET /admin/documents def index - @documents = PgSearch::Document.featureable.includes(:searchable).order(featured_position: :asc).select(&:searchable) + @documents = Document.featureable.includes(:searchable).order(featured_position: :asc).select(&:searchable) end # GET /admin/documents/1/edit @@ -32,14 +32,14 @@ def hide end def reposition - PgSearch::Document.reposition_all + Document.reposition_all redirect_to admin_documents_path, notice: 'Documents were successfully repositioned.' end private def set_document - @document = PgSearch::Document.find(params[:id]) + @document = Document.find(params[:id]) end def document_params diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 85eea7ff..83df2440 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -5,7 +5,7 @@ def index @faqs = Page.faq.all # TODO: fetch top FAQs here @journeys = Journey.published - @documents = PgSearch::Document.featured.includes(:searchable).order(featured_position: :asc).map(&:searchable).compact # we do not have FK constraints here, compact eliminates any possible documents hanging without searchable counterpart, which was deleted + @documents = Document.featured.includes(:searchable).order(featured_position: :asc).map(&:searchable).compact # we do not have FK constraints here, compact eliminates any possible documents hanging without searchable counterpart, which was deleted end def show diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb index 17094726..a1898cb2 100644 --- a/app/controllers/searches_controller.rb +++ b/app/controllers/searches_controller.rb @@ -4,7 +4,7 @@ class SearchesController < ApplicationController def show @q = params[:q] @analyzed_q = Transliterator.transliterate(@q) - @searches = PgSearch::Document + @searches = Document .where(searchable_type: %w(Page Journey App)) .search(@analyzed_q) .page(params[:page]) diff --git a/app/helpers/journeys_helper.rb b/app/helpers/journeys_helper.rb index 5a6d795b..597a29d6 100644 --- a/app/helpers/journeys_helper.rb +++ b/app/helpers/journeys_helper.rb @@ -4,7 +4,7 @@ def how_to_json_ld(journey) '@context' => 'http://schema.org', '@type' => 'HowTo', 'description' => sanitize_description(journey.description).to_str, - 'image' => image_url("journeys/#{journey.image_name}"), + 'image' => image_url("journeys/#{@journey.image_name.presence || "placeholder.png" }"), 'name' => journey.title, 'step' => journey.steps.map.with_index(1) do |step, idx| { diff --git a/app/models/app.rb b/app/models/app.rb index f9265ab6..1ff70c3c 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -4,7 +4,7 @@ class App < ApplicationRecord scope :published, -> { where(published_status: 'PUBLISHED')} - has_many :search_documents, :class_name => 'PgSearch::Document', as: :searchable + has_many :search_documents, :class_name => 'Document', as: :searchable enumerates :published_status, with: %w{DRAFT PUBLISHED} diff --git a/app/models/pg_search/document.rb b/app/models/document.rb similarity index 80% rename from app/models/pg_search/document.rb rename to app/models/document.rb index 782a8909..d75e3251 100644 --- a/app/models/pg_search/document.rb +++ b/app/models/document.rb @@ -1,7 +1,5 @@ -class PgSearch::Document < ::ActiveRecord::Base +class Document < ::PgSearch::Document include Searchable - self.table_name = 'pg_search_documents' - belongs_to :searchable, polymorphic: true scope :featureable, -> { where(searchable_type: ['Journey', 'App', 'Page']) } scope :featured, -> { featureable.where(featured: true) } diff --git a/app/models/journey.rb b/app/models/journey.rb index 37ffed1c..8b717499 100644 --- a/app/models/journey.rb +++ b/app/models/journey.rb @@ -14,7 +14,7 @@ class Journey < ApplicationRecord enumerates :published_status, with: %w{DRAFT PUBLISHED BLANK} - has_many :search_documents, :class_name => 'PgSearch::Document', as: :searchable + has_many :search_documents, :class_name => 'Document', as: :searchable validates :title, presence: true validates :slug, presence: true, uniqueness: true @@ -82,6 +82,6 @@ def join_search(arr) end def steps_search(column) - PgSearch::Document.where(searchable: steps).pluck(column).join(' ') + Document.where(searchable: steps).pluck(column).join(' ') end end diff --git a/app/views/searches/_journey.html.erb b/app/views/searches/_journey.html.erb index 3708cb6f..c1a7fc6d 100644 --- a/app/views/searches/_journey.html.erb +++ b/app/views/searches/_journey.html.erb @@ -5,7 +5,7 @@
<%= searched_text(journey.description, query) %>
- <% steps = PgSearch::Document.where(searchable: journey.steps).search(analyzed_query).page(1).per(4) %> + <% steps = Document.where(searchable: journey.steps).search(analyzed_query).page(1).per(4) %> <% if steps.count == 1 %>