Skip to content

Commit b09944e

Browse files
committed
Rename MeiliSearch to Meilisearch
Depends on meilisearch-ruby 0.30 where MeiliSearch was also renamed. Used this shell command to automatically rename, and then used the git diff to manually look through and make sure nothing was wrong: find lib/ -type f -exec sed -i 's/MeiliSearch/Meilisearch/g' {} \; (of course also ran it for spec/ and playground/ after making sure the soft deprecation allowed all tests to pass). Ran into issues with the regular `const_missing` + `const_get` deprecation having issues with autoload-ed methods. Added a temporary workaround just for the Rails module. With this workaround there may be cases where users are not warned for using MeiliSearch, which should be investigated.
1 parent 5c408f1 commit b09944e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+191
-185
lines changed

README.md

+35-35
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ gem 'meilisearch-rails'
9898
Create a new file `config/initializers/meilisearch.rb` to setup your `MEILISEARCH_HOST` and `MEILISEARCH_API_KEY`
9999

100100
```ruby
101-
MeiliSearch::Rails.configuration = {
101+
Meilisearch::Rails.configuration = {
102102
meilisearch_url: ENV.fetch('MEILISEARCH_HOST', 'http://localhost:7700'),
103103
meilisearch_api_key: ENV.fetch('MEILISEARCH_API_KEY', 'YourMeilisearchAPIKey')
104104
}
@@ -120,7 +120,7 @@ The following code will create a `Book` index and add search capabilities to you
120120

121121
```ruby
122122
class Book < ActiveRecord::Base
123-
include MeiliSearch::Rails
123+
include Meilisearch::Rails
124124

125125
meilisearch do
126126
attribute :title, :author # only the attributes 'title', and 'author' will be sent to Meilisearch
@@ -154,7 +154,7 @@ Requests made to Meilisearch may timeout and retry. To adapt the behavior to
154154
your needs, you can change the parameters during configuration:
155155

156156
```ruby
157-
MeiliSearch::Rails.configuration = {
157+
Meilisearch::Rails.configuration = {
158158
meilisearch_url: 'YourMeilisearchUrl',
159159
meilisearch_api_key: 'YourMeilisearchAPIKey',
160160
timeout: 2,
@@ -172,7 +172,7 @@ You can configure the index settings by adding them inside the `meilisearch` blo
172172

173173
```ruby
174174
class Book < ApplicationRecord
175-
include MeiliSearch::Rails
175+
include Meilisearch::Rails
176176

177177
meilisearch do
178178
searchable_attributes [:title, :author, :publisher, :description]
@@ -235,7 +235,7 @@ Book.search('*', sort: ['title:asc'])
235235
Meilisearch supports searching multiple models at the same time (see [🔍 Custom search](#-custom-search) for search options):
236236

237237
```ruby
238-
multi_search_results = MeiliSearch::Rails.multi_search(
238+
multi_search_results = Meilisearch::Rails.multi_search(
239239
Book => { q: 'Harry' },
240240
Manga => { q: 'Attack' }
241241
)
@@ -295,7 +295,7 @@ This gem supports:
295295
Specify the `:pagination_backend` in the configuration file:
296296

297297
```ruby
298-
MeiliSearch::Rails.configuration = {
298+
Meilisearch::Rails.configuration = {
299299
meilisearch_url: 'YourMeilisearchUrl',
300300
meilisearch_api_key: 'YourMeilisearchAPIKey',
301301
pagination_backend: :kaminari # :will_paginate
@@ -344,7 +344,7 @@ Then in your model you must extend `Pagy::Meilisearch`:
344344

345345
```rb
346346
class Book < ApplicationRecord
347-
include MeiliSearch::Rails
347+
include Meilisearch::Rails
348348
extend Pagy::Meilisearch
349349

350350
meilisearch # ...
@@ -365,7 +365,7 @@ end
365365
<%== pagy_nav(@pagy) %>
366366
```
367367
368-
:warning: There is no need to set `pagination_backend` in the configuration block `MeiliSearch::Rails.configuration` for `pagy`.
368+
:warning: There is no need to set `pagination_backend` in the configuration block `Meilisearch::Rails.configuration` for `pagy`.
369369
370370
Check [`ddnexus/pagy`](https://ddnexus.github.io/pagy/extras/meilisearch) for more information.
371371
@@ -377,7 +377,7 @@ you have multiple ways to achieve this.
377377
By adding `active: false` in the configuration initializer:
378378

379379
```ruby
380-
MeiliSearch::Rails.configuration = {
380+
Meilisearch::Rails.configuration = {
381381
meilisearch_url: 'YourMeilisearchUrl',
382382
meilisearch_api_key: 'YourMeilisearchAPIKey',
383383
active: false
@@ -387,11 +387,11 @@ MeiliSearch::Rails.configuration = {
387387
Or you can disable programmatically:
388388

389389
```ruby
390-
MeiliSearch::Rails.deactivate! # all the following HTTP calls will be dismissed.
390+
Meilisearch::Rails.deactivate! # all the following HTTP calls will be dismissed.
391391
392392
# or you can pass a block to it:
393393
394-
MeiliSearch::Rails.deactivate! do
394+
Meilisearch::Rails.deactivate! do
395395
# every Meilisearch call here will be dismissed, no error will be raised.
396396
# after the block, Meilisearch state will be active.
397397
end
@@ -400,7 +400,7 @@ end
400400
You can also activate if you deactivated earlier:
401401

402402
```ruby
403-
MeiliSearch::Rails.activate!
403+
Meilisearch::Rails.activate!
404404
```
405405

406406
:warning: These calls are persistent, so prefer to use the method with the block. This way, you will not forget to activate it afterward.
@@ -411,7 +411,7 @@ By default, the **index_uid** will be the class name, e.g. `Book`. You can custo
411411

412412
```ruby
413413
class Book < ActiveRecord::Base
414-
include MeiliSearch::Rails
414+
include Meilisearch::Rails
415415
416416
meilisearch index_uid: 'MyCustomUID'
417417
end
@@ -422,7 +422,7 @@ end
422422
You can suffix the index UID with the current Rails environment by setting it globally:
423423

424424
```ruby
425-
MeiliSearch::Rails.configuration = {
425+
Meilisearch::Rails.configuration = {
426426
meilisearch_url: 'YourMeilisearchUrl',
427427
meilisearch_api_key: 'YourMeilisearchAPIKey',
428428
per_environment: true
@@ -441,7 +441,7 @@ You can add a custom attribute by using the `add_attribute` option or by using a
441441
442442
```ruby
443443
class Author < ApplicationRecord
444-
include MeiliSearch::Rails
444+
include Meilisearch::Rails
445445
446446
meilisearch do
447447
attribute :first_name, :last_name
@@ -473,7 +473,7 @@ Note that the primary key must return a **unique value** otherwise your data cou
473473

474474
```ruby
475475
class Book < ActiveRecord::Base
476-
include MeiliSearch::Rails
476+
include Meilisearch::Rails
477477
478478
meilisearch primary_key: :isbn # isbn is a column in your table definition.
479479
end
@@ -484,7 +484,7 @@ will be used as the reference to the document when Meilisearch needs it.
484484

485485
```rb
486486
class Book < ActiveRecord::Base
487-
include MeiliSearch::Rails
487+
include Meilisearch::Rails
488488
489489
meilisearch primary_key: :my_custom_ms_id
490490
@@ -503,7 +503,7 @@ As soon as you use those constraints, `add_documents` and `delete_documents` cal
503503

504504
```ruby
505505
class Book < ActiveRecord::Base
506-
include MeiliSearch::Rails
506+
include Meilisearch::Rails
507507
508508
meilisearch if: :published?, unless: :premium?
509509
@@ -526,7 +526,7 @@ You can index a record in several indexes using the `add_index` option:
526526

527527
```ruby
528528
class Book < ActiveRecord::Base
529-
include MeiliSearch::Rails
529+
include Meilisearch::Rails
530530
531531
PUBLIC_INDEX_UID = 'Books'
532532
SECURED_INDEX_UID = 'PrivateBooks'
@@ -555,7 +555,7 @@ You may want to share an index between several models. You'll need to ensure you
555555

556556
```ruby
557557
class Cat < ActiveRecord::Base
558-
include MeiliSearch::Rails
558+
include Meilisearch::Rails
559559
560560
meilisearch index_uid: 'Animals', primary_key: :ms_id
561561
@@ -567,7 +567,7 @@ class Cat < ActiveRecord::Base
567567
end
568568
569569
class Dog < ActiveRecord::Base
570-
include MeiliSearch::Rails
570+
include Meilisearch::Rails
571571
572572
meilisearch index_uid: 'Animals', primary_key: :ms_id
573573
@@ -585,7 +585,7 @@ You can configure the auto-indexing & auto-removal process to use a queue to per
585585

586586
```ruby
587587
class Book < ActiveRecord::Base
588-
include MeiliSearch::Rails
588+
include Meilisearch::Rails
589589
590590
meilisearch enqueue: true # ActiveJob will be triggered using a `meilisearch` queue
591591
end
@@ -599,7 +599,7 @@ With **ActiveJob**:
599599

600600
```ruby
601601
class Book < ActiveRecord::Base
602-
include MeiliSearch::Rails
602+
include Meilisearch::Rails
603603
604604
meilisearch enqueue: :trigger_job do
605605
attribute :title, :author, :description
@@ -629,7 +629,7 @@ With [**Sidekiq**](https://github.com/mperham/sidekiq):
629629

630630
```ruby
631631
class Book < ActiveRecord::Base
632-
include MeiliSearch::Rails
632+
include Meilisearch::Rails
633633
634634
meilisearch enqueue: :trigger_sidekiq_job do
635635
attribute :title, :author, :description
@@ -659,7 +659,7 @@ With [**DelayedJob**](https://github.com/collectiveidea/delayed_job):
659659

660660
```ruby
661661
class Book < ActiveRecord::Base
662-
include MeiliSearch::Rails
662+
include Meilisearch::Rails
663663
664664
meilisearch enqueue: :trigger_delayed_job do
665665
attribute :title, :author, :description
@@ -683,7 +683,7 @@ Extend a change to a related record.
683683
684684
```ruby
685685
class Author < ActiveRecord::Base
686-
include MeiliSearch::Rails
686+
include Meilisearch::Rails
687687
688688
has_many :books
689689
# If your association uses belongs_to
@@ -693,7 +693,7 @@ class Author < ActiveRecord::Base
693693
end
694694
695695
class Book < ActiveRecord::Base
696-
include MeiliSearch::Rails
696+
include Meilisearch::Rails
697697
698698
belongs_to :author
699699
after_touch :index!
@@ -712,7 +712,7 @@ With **Sequel**, you can use the `touch` plugin to propagate changes.
712712
```ruby
713713
# app/models/author.rb
714714
class Author < Sequel::Model
715-
include MeiliSearch::Rails
715+
include Meilisearch::Rails
716716
717717
one_to_many :books
718718
@@ -734,7 +734,7 @@ end
734734
735735
# app/models/book.rb
736736
class Book < Sequel::Model
737-
include MeiliSearch::Rails
737+
include Meilisearch::Rails
738738
739739
many_to_one :author
740740
after_touch :index!
@@ -757,7 +757,7 @@ You can strip all HTML tags from your attributes with the `sanitize` option.
757757
758758
```ruby
759759
class Book < ActiveRecord::Base
760-
include MeiliSearch::Rails
760+
include Meilisearch::Rails
761761
762762
meilisearch sanitize: true
763763
end
@@ -769,7 +769,7 @@ You can force the UTF-8 encoding of all your attributes using the `force_utf8_en
769769
770770
```ruby
771771
class Book < ActiveRecord::Base
772-
include MeiliSearch::Rails
772+
include Meilisearch::Rails
773773
774774
meilisearch force_utf8_encoding: true
775775
end
@@ -781,7 +781,7 @@ You can eager load associations using `meilisearch_import` scope.
781781
782782
```ruby
783783
class Author < ActiveRecord::Base
784-
include MeiliSearch::Rails
784+
include Meilisearch::Rails
785785
786786
has_many :books
787787
@@ -834,7 +834,7 @@ You can disable exceptions that could be raised while trying to reach Meilisearc
834834

835835
```ruby
836836
class Book < ActiveRecord::Base
837-
include MeiliSearch::Rails
837+
include Meilisearch::Rails
838838

839839
# Only raise exceptions in development environment.
840840
meilisearch raise_on_failure: Rails.env.development?
@@ -849,7 +849,7 @@ You can force indexing and removing to be synchronous by setting the following o
849849

850850
```ruby
851851
class Book < ActiveRecord::Base
852-
include MeiliSearch::Rails
852+
include Meilisearch::Rails
853853

854854
meilisearch synchronous: true
855855
end
@@ -862,7 +862,7 @@ You can disable auto-indexing and auto-removing setting the following options:
862862

863863
```ruby
864864
class Book < ActiveRecord::Base
865-
include MeiliSearch::Rails
865+
include Meilisearch::Rails
866866

867867
meilisearch auto_index: false, auto_remove: false
868868
end

0 commit comments

Comments
 (0)