algoliasearch-rails 1.11.11 → 1.11.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/README.md +37 -5
- data/VERSION +1 -1
- data/lib/algoliasearch-rails.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8acb586d687a6f969b2bf65d918df3d90928fa2
|
4
|
+
data.tar.gz: 1ecee0a5c9d4397e52e194982ce77e370def3452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c787e1009b2ad28c6cd2098c32c629bb74602ee18b4646b6f8625c23b51d448227aee631ca27b205e292f9ee26feb7f971a93492bfca6805fff528085da116
|
7
|
+
data.tar.gz: 0bb8c9eba4902b3ac0a11ab9aaa0660a2daf45b547ff9fc5d1287f31c9aa3adf5c051dcc0588a63da223cccb695abe792cbf82cc2271be98da5151c8b61acf01
|
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
Algolia Search for Rails
|
2
2
|
==================
|
3
3
|
|
4
|
-
This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem.
|
4
|
+
This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem. Both Rails 3.x and Rails 4.x are supported.
|
5
5
|
|
6
6
|
You might be interested in the sample Ruby on Rails application providing a ```typeahead.js```-based auto-completion and ```Google```-like instant search: [algoliasearch-rails-example](https://github.com/algolia/algoliasearch-rails-example/).
|
7
7
|
|
8
8
|
[![Build Status](https://travis-ci.org/algolia/algoliasearch-rails.png?branch=master)](https://travis-ci.org/algolia/algoliasearch-rails) [![Gem Version](https://badge.fury.io/rb/algoliasearch-rails.png)](http://badge.fury.io/rb/algoliasearch-rails) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-rails.png)](https://codeclimate.com/github/algolia/algoliasearch-rails)
|
9
9
|
|
10
|
-
|
11
10
|
Table of Content
|
12
11
|
-------------
|
13
12
|
**Get started**
|
@@ -35,7 +34,7 @@ Install
|
|
35
34
|
gem install algoliasearch-rails
|
36
35
|
```
|
37
36
|
|
38
|
-
|
37
|
+
Add the gem to your <code>Gemfile</code>:
|
39
38
|
|
40
39
|
```ruby
|
41
40
|
gem "algoliasearch-rails"
|
@@ -163,7 +162,7 @@ You can temporary disable auto-indexing using the <code>without_auto_index</code
|
|
163
162
|
```ruby
|
164
163
|
Contact.delete_all
|
165
164
|
Contact.without_auto_index do
|
166
|
-
1.upto(10000) { Contact.create! attributes } # inside
|
165
|
+
1.upto(10000) { Contact.create! attributes } # inside this block, auto indexing task will not run.
|
167
166
|
end
|
168
167
|
Contact.reindex! # will use batch operations
|
169
168
|
```
|
@@ -182,7 +181,7 @@ end
|
|
182
181
|
|
183
182
|
#### Custom index name
|
184
183
|
|
185
|
-
You can
|
184
|
+
By default, the index name will be the class name, e.g. "Contact". You can customize the index name by using the `index_name` option:
|
186
185
|
|
187
186
|
```ruby
|
188
187
|
class Contact < ActiveRecord::Base
|
@@ -249,6 +248,32 @@ class Contact < ActiveRecord::Base
|
|
249
248
|
end
|
250
249
|
```
|
251
250
|
|
251
|
+
#### Nested objects/relations
|
252
|
+
|
253
|
+
You can easily embed nested objects defining an extra attribute returning any JSON-compliant object (an array or a hash or a combination of both).
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
class Profile < ActiveRecord::Base
|
257
|
+
include AlgoliaSearch
|
258
|
+
|
259
|
+
belongs_to :user
|
260
|
+
has_many :specializations
|
261
|
+
|
262
|
+
algoliasearch do
|
263
|
+
attribute :user do
|
264
|
+
# restrict the nested "user" object to its `name` + `email`
|
265
|
+
{ name: user.name, email: user.email }
|
266
|
+
end
|
267
|
+
attribute :public_specializations do
|
268
|
+
# build an array of public specialization (include only `title` and `another_attr`)
|
269
|
+
specializations.select { |s| s.public? }.map do |s|
|
270
|
+
{ title: s.title, another_attr: s.another_attr }
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
```
|
252
277
|
|
253
278
|
#### Custom ```objectID```
|
254
279
|
|
@@ -332,6 +357,13 @@ end
|
|
332
357
|
|
333
358
|
```
|
334
359
|
|
360
|
+
If you're using Rails 4.2+, you also need to depend on `rails-html-sanitizer`:
|
361
|
+
|
362
|
+
```ruby
|
363
|
+
gem 'rails-html-sanitizer'
|
364
|
+
```
|
365
|
+
|
366
|
+
|
335
367
|
#### UTF-8 Encoding
|
336
368
|
|
337
369
|
You can force the UTF-8 encoding of all your attributes using the ```force_utf8_encoding``` option:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.11.
|
1
|
+
1.11.12
|
data/lib/algoliasearch-rails.rb
CHANGED
@@ -103,7 +103,12 @@ module AlgoliaSearch
|
|
103
103
|
end
|
104
104
|
|
105
105
|
if @options[:sanitize]
|
106
|
-
sanitizer =
|
106
|
+
sanitizer = begin
|
107
|
+
::HTML::FullSanitizer.new
|
108
|
+
rescue NameError
|
109
|
+
# from rails 4.2
|
110
|
+
::Rails::Html::FullSanitizer.new
|
111
|
+
end
|
107
112
|
attributes = sanitize_attributes(attributes, sanitizer)
|
108
113
|
end
|
109
114
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|