elasticsearch-persistence 5.0.2 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +2 -0
- data/Gemfile +9 -0
- data/README.md +206 -338
- data/Rakefile +15 -12
- data/elasticsearch-persistence.gemspec +6 -7
- data/examples/notes/application.rb +3 -4
- data/lib/elasticsearch/persistence.rb +2 -110
- data/lib/elasticsearch/persistence/repository.rb +212 -53
- data/lib/elasticsearch/persistence/repository/dsl.rb +94 -0
- data/lib/elasticsearch/persistence/repository/find.rb +27 -10
- data/lib/elasticsearch/persistence/repository/response/results.rb +21 -8
- data/lib/elasticsearch/persistence/repository/search.rb +30 -18
- data/lib/elasticsearch/persistence/repository/serialize.rb +65 -7
- data/lib/elasticsearch/persistence/repository/store.rb +38 -44
- data/lib/elasticsearch/persistence/version.rb +1 -1
- data/spec/repository/find_spec.rb +179 -0
- data/spec/repository/response/results_spec.rb +128 -0
- data/spec/repository/search_spec.rb +181 -0
- data/spec/repository/serialize_spec.rb +53 -0
- data/spec/repository/store_spec.rb +327 -0
- data/spec/repository_spec.rb +723 -0
- data/spec/spec_helper.rb +32 -0
- metadata +26 -104
- data/examples/music/album.rb +0 -54
- data/examples/music/artist.rb +0 -70
- data/examples/music/artists/_form.html.erb +0 -8
- data/examples/music/artists/artists_controller.rb +0 -67
- data/examples/music/artists/artists_controller_test.rb +0 -53
- data/examples/music/artists/index.html.erb +0 -60
- data/examples/music/artists/show.html.erb +0 -54
- data/examples/music/assets/application.css +0 -257
- data/examples/music/assets/autocomplete.css +0 -48
- data/examples/music/assets/blank_artist.png +0 -0
- data/examples/music/assets/blank_cover.png +0 -0
- data/examples/music/assets/form.css +0 -113
- data/examples/music/index_manager.rb +0 -73
- data/examples/music/search/index.html.erb +0 -95
- data/examples/music/search/search_controller.rb +0 -41
- data/examples/music/search/search_controller_test.rb +0 -12
- data/examples/music/search/search_helper.rb +0 -15
- data/examples/music/suggester.rb +0 -69
- data/examples/music/template.rb +0 -430
- data/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.css +0 -7
- data/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.js +0 -6
- data/examples/music/vendor/assets/stylesheets/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/elasticsearch/persistence/client.rb +0 -51
- data/lib/elasticsearch/persistence/model.rb +0 -135
- data/lib/elasticsearch/persistence/model/base.rb +0 -87
- data/lib/elasticsearch/persistence/model/errors.rb +0 -8
- data/lib/elasticsearch/persistence/model/find.rb +0 -180
- data/lib/elasticsearch/persistence/model/rails.rb +0 -47
- data/lib/elasticsearch/persistence/model/store.rb +0 -254
- data/lib/elasticsearch/persistence/model/utils.rb +0 -0
- data/lib/elasticsearch/persistence/repository/class.rb +0 -71
- data/lib/elasticsearch/persistence/repository/naming.rb +0 -115
- data/lib/rails/generators/elasticsearch/model/model_generator.rb +0 -21
- data/lib/rails/generators/elasticsearch/model/templates/model.rb.tt +0 -9
- data/lib/rails/generators/elasticsearch_generator.rb +0 -2
- data/test/integration/model/model_basic_test.rb +0 -233
- data/test/integration/repository/custom_class_test.rb +0 -85
- data/test/integration/repository/customized_class_test.rb +0 -82
- data/test/integration/repository/default_class_test.rb +0 -116
- data/test/integration/repository/virtus_model_test.rb +0 -118
- data/test/test_helper.rb +0 -55
- data/test/unit/model_base_test.rb +0 -72
- data/test/unit/model_find_test.rb +0 -153
- data/test/unit/model_gateway_test.rb +0 -101
- data/test/unit/model_rails_test.rb +0 -112
- data/test/unit/model_store_test.rb +0 -576
- data/test/unit/persistence_test.rb +0 -32
- data/test/unit/repository_class_test.rb +0 -51
- data/test/unit/repository_client_test.rb +0 -32
- data/test/unit/repository_find_test.rb +0 -388
- data/test/unit/repository_indexing_test.rb +0 -37
- data/test/unit/repository_module_test.rb +0 -146
- data/test/unit/repository_naming_test.rb +0 -146
- data/test/unit/repository_response_results_test.rb +0 -98
- data/test/unit/repository_search_test.rb +0 -117
- data/test/unit/repository_serialize_test.rb +0 -57
- data/test/unit/repository_store_test.rb +0 -303
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'pry-nav'
|
2
|
+
require 'elasticsearch/persistence'
|
3
|
+
|
4
|
+
unless defined?(ELASTICSEARCH_URL)
|
5
|
+
ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.formatter = 'documentation'
|
10
|
+
config.color = true
|
11
|
+
|
12
|
+
config.after(:suite) do
|
13
|
+
DEFAULT_CLIENT.indices.delete(index: '_all')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# The default client to be used by the repositories.
|
18
|
+
#
|
19
|
+
# @since 6.0.0
|
20
|
+
DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL,
|
21
|
+
tracer: (ENV['QUIET'] ? nil : ::Logger.new(STDERR)))
|
22
|
+
|
23
|
+
class MyTestRepository
|
24
|
+
include Elasticsearch::Persistence::Repository
|
25
|
+
include Elasticsearch::Persistence::Repository::DSL
|
26
|
+
client DEFAULT_CLIENT
|
27
|
+
end
|
28
|
+
|
29
|
+
# The default repository to be used by tests.
|
30
|
+
#
|
31
|
+
# @since 6.0.0
|
32
|
+
DEFAULT_REPOSITORY = MyTestRepository.new(index_name: 'my_test_repository', document_type: 'test')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-persistence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -16,26 +16,26 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: elasticsearch-model
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -81,33 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
|
-
type: :
|
90
|
+
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: bundler
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.5'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.5'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: rake
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -314,34 +300,13 @@ extra_rdoc_files:
|
|
314
300
|
- LICENSE.txt
|
315
301
|
files:
|
316
302
|
- ".gitignore"
|
303
|
+
- ".rspec"
|
317
304
|
- CHANGELOG.md
|
318
305
|
- Gemfile
|
319
306
|
- LICENSE.txt
|
320
307
|
- README.md
|
321
308
|
- Rakefile
|
322
309
|
- elasticsearch-persistence.gemspec
|
323
|
-
- examples/music/album.rb
|
324
|
-
- examples/music/artist.rb
|
325
|
-
- examples/music/artists/_form.html.erb
|
326
|
-
- examples/music/artists/artists_controller.rb
|
327
|
-
- examples/music/artists/artists_controller_test.rb
|
328
|
-
- examples/music/artists/index.html.erb
|
329
|
-
- examples/music/artists/show.html.erb
|
330
|
-
- examples/music/assets/application.css
|
331
|
-
- examples/music/assets/autocomplete.css
|
332
|
-
- examples/music/assets/blank_artist.png
|
333
|
-
- examples/music/assets/blank_cover.png
|
334
|
-
- examples/music/assets/form.css
|
335
|
-
- examples/music/index_manager.rb
|
336
|
-
- examples/music/search/index.html.erb
|
337
|
-
- examples/music/search/search_controller.rb
|
338
|
-
- examples/music/search/search_controller_test.rb
|
339
|
-
- examples/music/search/search_helper.rb
|
340
|
-
- examples/music/suggester.rb
|
341
|
-
- examples/music/template.rb
|
342
|
-
- examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.css
|
343
|
-
- examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.js
|
344
|
-
- examples/music/vendor/assets/stylesheets/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
|
345
310
|
- examples/notes/.gitignore
|
346
311
|
- examples/notes/Gemfile
|
347
312
|
- examples/notes/README.markdown
|
@@ -349,48 +314,21 @@ files:
|
|
349
314
|
- examples/notes/config.ru
|
350
315
|
- examples/notes/test.rb
|
351
316
|
- lib/elasticsearch/persistence.rb
|
352
|
-
- lib/elasticsearch/persistence/client.rb
|
353
|
-
- lib/elasticsearch/persistence/model.rb
|
354
|
-
- lib/elasticsearch/persistence/model/base.rb
|
355
|
-
- lib/elasticsearch/persistence/model/errors.rb
|
356
|
-
- lib/elasticsearch/persistence/model/find.rb
|
357
|
-
- lib/elasticsearch/persistence/model/rails.rb
|
358
|
-
- lib/elasticsearch/persistence/model/store.rb
|
359
|
-
- lib/elasticsearch/persistence/model/utils.rb
|
360
317
|
- lib/elasticsearch/persistence/repository.rb
|
361
|
-
- lib/elasticsearch/persistence/repository/
|
318
|
+
- lib/elasticsearch/persistence/repository/dsl.rb
|
362
319
|
- lib/elasticsearch/persistence/repository/find.rb
|
363
|
-
- lib/elasticsearch/persistence/repository/naming.rb
|
364
320
|
- lib/elasticsearch/persistence/repository/response/results.rb
|
365
321
|
- lib/elasticsearch/persistence/repository/search.rb
|
366
322
|
- lib/elasticsearch/persistence/repository/serialize.rb
|
367
323
|
- lib/elasticsearch/persistence/repository/store.rb
|
368
324
|
- lib/elasticsearch/persistence/version.rb
|
369
|
-
-
|
370
|
-
-
|
371
|
-
-
|
372
|
-
-
|
373
|
-
-
|
374
|
-
-
|
375
|
-
-
|
376
|
-
- test/integration/repository/virtus_model_test.rb
|
377
|
-
- test/test_helper.rb
|
378
|
-
- test/unit/model_base_test.rb
|
379
|
-
- test/unit/model_find_test.rb
|
380
|
-
- test/unit/model_gateway_test.rb
|
381
|
-
- test/unit/model_rails_test.rb
|
382
|
-
- test/unit/model_store_test.rb
|
383
|
-
- test/unit/persistence_test.rb
|
384
|
-
- test/unit/repository_class_test.rb
|
385
|
-
- test/unit/repository_client_test.rb
|
386
|
-
- test/unit/repository_find_test.rb
|
387
|
-
- test/unit/repository_indexing_test.rb
|
388
|
-
- test/unit/repository_module_test.rb
|
389
|
-
- test/unit/repository_naming_test.rb
|
390
|
-
- test/unit/repository_response_results_test.rb
|
391
|
-
- test/unit/repository_search_test.rb
|
392
|
-
- test/unit/repository_serialize_test.rb
|
393
|
-
- test/unit/repository_store_test.rb
|
325
|
+
- spec/repository/find_spec.rb
|
326
|
+
- spec/repository/response/results_spec.rb
|
327
|
+
- spec/repository/search_spec.rb
|
328
|
+
- spec/repository/serialize_spec.rb
|
329
|
+
- spec/repository/store_spec.rb
|
330
|
+
- spec/repository_spec.rb
|
331
|
+
- spec/spec_helper.rb
|
394
332
|
homepage: https://github.com/elasticsearch/elasticsearch-rails/
|
395
333
|
licenses:
|
396
334
|
- Apache 2
|
@@ -404,38 +342,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
404
342
|
requirements:
|
405
343
|
- - ">="
|
406
344
|
- !ruby/object:Gem::Version
|
407
|
-
version:
|
345
|
+
version: '2.2'
|
408
346
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
409
347
|
requirements:
|
410
348
|
- - ">="
|
411
349
|
- !ruby/object:Gem::Version
|
412
350
|
version: '0'
|
413
351
|
requirements: []
|
414
|
-
|
415
|
-
rubygems_version: 2.5.2
|
352
|
+
rubygems_version: 3.1.2
|
416
353
|
signing_key:
|
417
354
|
specification_version: 4
|
418
355
|
summary: Persistence layer for Ruby models and Elasticsearch.
|
419
356
|
test_files:
|
420
|
-
-
|
421
|
-
-
|
422
|
-
-
|
423
|
-
-
|
424
|
-
-
|
425
|
-
-
|
426
|
-
-
|
427
|
-
- test/unit/model_find_test.rb
|
428
|
-
- test/unit/model_gateway_test.rb
|
429
|
-
- test/unit/model_rails_test.rb
|
430
|
-
- test/unit/model_store_test.rb
|
431
|
-
- test/unit/persistence_test.rb
|
432
|
-
- test/unit/repository_class_test.rb
|
433
|
-
- test/unit/repository_client_test.rb
|
434
|
-
- test/unit/repository_find_test.rb
|
435
|
-
- test/unit/repository_indexing_test.rb
|
436
|
-
- test/unit/repository_module_test.rb
|
437
|
-
- test/unit/repository_naming_test.rb
|
438
|
-
- test/unit/repository_response_results_test.rb
|
439
|
-
- test/unit/repository_search_test.rb
|
440
|
-
- test/unit/repository_serialize_test.rb
|
441
|
-
- test/unit/repository_store_test.rb
|
357
|
+
- spec/repository/find_spec.rb
|
358
|
+
- spec/repository/response/results_spec.rb
|
359
|
+
- spec/repository/search_spec.rb
|
360
|
+
- spec/repository/serialize_spec.rb
|
361
|
+
- spec/repository/store_spec.rb
|
362
|
+
- spec/repository_spec.rb
|
363
|
+
- spec/spec_helper.rb
|
data/examples/music/album.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
class Meta
|
2
|
-
include Virtus.model
|
3
|
-
|
4
|
-
attribute :rating
|
5
|
-
attribute :have
|
6
|
-
attribute :want
|
7
|
-
attribute :formats
|
8
|
-
end
|
9
|
-
|
10
|
-
class Album
|
11
|
-
include Elasticsearch::Persistence::Model
|
12
|
-
|
13
|
-
index_name [Rails.application.engine_name, Rails.env].join('-')
|
14
|
-
|
15
|
-
|
16
|
-
mapping _parent: { type: 'artist' } do
|
17
|
-
end
|
18
|
-
|
19
|
-
attribute :artist
|
20
|
-
attribute :artist_id, String, mapping: { index: 'not_analyzed' }
|
21
|
-
attribute :label, Hash, mapping: { type: 'object' }
|
22
|
-
|
23
|
-
attribute :title
|
24
|
-
attribute :released, Date
|
25
|
-
attribute :notes
|
26
|
-
attribute :uri
|
27
|
-
|
28
|
-
attribute :tracklist, Array, mapping: { type: 'object' }
|
29
|
-
|
30
|
-
attribute :styles
|
31
|
-
attribute :meta, Meta, mapping: { type: 'object' }
|
32
|
-
|
33
|
-
attribute :suggest, Hashie::Mash, mapping: {
|
34
|
-
type: 'object',
|
35
|
-
properties: {
|
36
|
-
title: {
|
37
|
-
type: 'object',
|
38
|
-
properties: {
|
39
|
-
input: { type: 'completion' },
|
40
|
-
output: { type: 'keyword', index: false },
|
41
|
-
payload: { type: 'object', enabled: false }
|
42
|
-
}
|
43
|
-
},
|
44
|
-
track: {
|
45
|
-
type: 'object',
|
46
|
-
properties: {
|
47
|
-
input: { type: 'completion' },
|
48
|
-
output: { type: 'keyword', index: false },
|
49
|
-
payload: { type: 'object', enabled: false }
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
end
|
data/examples/music/artist.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
class Artist
|
2
|
-
include Elasticsearch::Persistence::Model
|
3
|
-
|
4
|
-
index_name [Rails.application.engine_name, Rails.env].join('-')
|
5
|
-
|
6
|
-
analyzed_and_raw = { fields: {
|
7
|
-
name: { type: 'text', analyzer: 'snowball' },
|
8
|
-
raw: { type: 'keyword' }
|
9
|
-
} }
|
10
|
-
|
11
|
-
attribute :name, String, mapping: analyzed_and_raw
|
12
|
-
|
13
|
-
attribute :profile
|
14
|
-
attribute :date, Date
|
15
|
-
|
16
|
-
attribute :members, String, default: [], mapping: analyzed_and_raw
|
17
|
-
attribute :members_combined, String, default: [], mapping: { analyzer: 'snowball' }
|
18
|
-
|
19
|
-
attribute :urls, String, default: []
|
20
|
-
attribute :album_count, Integer, default: 0
|
21
|
-
|
22
|
-
attribute :suggest, Hashie::Mash, mapping: {
|
23
|
-
type: 'object',
|
24
|
-
properties: {
|
25
|
-
name: {
|
26
|
-
type: 'object',
|
27
|
-
properties: {
|
28
|
-
input: { type: 'completion' },
|
29
|
-
output: { type: 'keyword', index: false },
|
30
|
-
payload: { type: 'object', enabled: false }
|
31
|
-
}
|
32
|
-
},
|
33
|
-
member: {
|
34
|
-
type: 'object',
|
35
|
-
properties: {
|
36
|
-
input: { type: 'completion' },
|
37
|
-
output: { type: 'keyword', index: false },
|
38
|
-
payload: { type: 'object', enabled: false }
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
validates :name, presence: true
|
45
|
-
|
46
|
-
def albums
|
47
|
-
Album.search(
|
48
|
-
{ query: {
|
49
|
-
has_parent: {
|
50
|
-
type: 'artist',
|
51
|
-
query: {
|
52
|
-
bool: {
|
53
|
-
filter: {
|
54
|
-
ids: { values: [ self.id ] }
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
59
|
-
},
|
60
|
-
sort: 'released',
|
61
|
-
size: 100
|
62
|
-
},
|
63
|
-
{ type: 'album' }
|
64
|
-
)
|
65
|
-
end
|
66
|
-
|
67
|
-
def to_param
|
68
|
-
[id, name.parameterize].join('-')
|
69
|
-
end
|
70
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<%= simple_form_for @artist do |f| %>
|
2
|
-
<%= f.input :name %>
|
3
|
-
<%= f.input :profile, as: :text %>
|
4
|
-
<%= f.input :date, as: :date %>
|
5
|
-
<%= f.input :members, hint: 'Separate names by comma', input_html: { value: f.object.members.join(', ') } %>
|
6
|
-
|
7
|
-
<%= f.button :submit %>
|
8
|
-
<% end %>
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class ArtistsController < ApplicationController
|
2
|
-
before_action :set_artist, only: [:show, :edit, :update, :destroy]
|
3
|
-
|
4
|
-
rescue_from Elasticsearch::Persistence::Repository::DocumentNotFound do
|
5
|
-
render file: "public/404.html", status: 404, layout: false
|
6
|
-
end
|
7
|
-
|
8
|
-
def index
|
9
|
-
@artists = Artist.all sort: 'name.raw', _source: ['name', 'album_count']
|
10
|
-
end
|
11
|
-
|
12
|
-
def show
|
13
|
-
@albums = @artist.albums
|
14
|
-
end
|
15
|
-
|
16
|
-
def new
|
17
|
-
@artist = Artist.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def edit
|
21
|
-
end
|
22
|
-
|
23
|
-
def create
|
24
|
-
@artist = Artist.new(artist_params)
|
25
|
-
|
26
|
-
respond_to do |format|
|
27
|
-
if @artist.save refresh: true
|
28
|
-
format.html { redirect_to @artist, notice: 'Artist was successfully created.' }
|
29
|
-
format.json { render :show, status: :created, location: @artist }
|
30
|
-
else
|
31
|
-
format.html { render :new }
|
32
|
-
format.json { render json: @artist.errors, status: :unprocessable_entity }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def update
|
38
|
-
respond_to do |format|
|
39
|
-
if @artist.update(artist_params, refresh: true)
|
40
|
-
format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }
|
41
|
-
format.json { render :show, status: :ok, location: @artist }
|
42
|
-
else
|
43
|
-
format.html { render :edit }
|
44
|
-
format.json { render json: @artist.errors, status: :unprocessable_entity }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def destroy
|
50
|
-
@artist.destroy refresh: true
|
51
|
-
respond_to do |format|
|
52
|
-
format.html { redirect_to artists_url, notice: 'Artist was successfully destroyed.' }
|
53
|
-
format.json { head :no_content }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
def set_artist
|
59
|
-
@artist = Artist.find(params[:id].split('-').first)
|
60
|
-
end
|
61
|
-
|
62
|
-
def artist_params
|
63
|
-
a = params.require(:artist)
|
64
|
-
a[:members] = a[:members].split(/,\s?/) unless a[:members].is_a?(Array) || a[:members].blank?
|
65
|
-
return a
|
66
|
-
end
|
67
|
-
end
|