Class: ForestLiana::AssociationsController
Constant Summary
ForestLiana::ApplicationController::REGEX_COOKIE_SESSION_TOKEN
Instance Method Summary
collapse
#authenticate_user_from_jwt, #forest_user, #get_smart_action_context, #internal_server_error, papertrail?, #route_not_found, #serialize_model, #serialize_models
Instance Method Details
#associate ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/forest_liana/associations_controller.rb', line 55
def associate
begin
associator = HasManyAssociator.new(@resource, @association, params)
associator.perform
head :no_content
rescue => error
FOREST_LOGGER.error "Association Associate error: #{error}\n#{format_stacktrace(error)}"
internal_server_error
end
end
|
#count ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/forest_liana/associations_controller.rb', line 26
def count
begin
getter = HasManyGetter.new(@resource, @association, params)
getter.count
render serializer: nil, json: { count: getter.records_count }
rescue => error
FOREST_LOGGER.error "Association Index Count error: #{error}\n#{format_stacktrace(error)}"
internal_server_error
end
end
|
#dissociate ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/forest_liana/associations_controller.rb', line 67
def dissociate
begin
dissociator = HasManyDissociator.new(@resource, @association, params)
dissociator.perform
head :no_content
rescue => error
FOREST_LOGGER.error "Association Associate error: #{error}\n#{format_stacktrace(error)}"
internal_server_error
end
end
|
#index ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/forest_liana/associations_controller.rb', line 11
def index
begin
getter = HasManyGetter.new(@resource, @association, params)
getter.perform
respond_to do |format|
format.json { render_jsonapi(getter) }
format.csv { render_csv(getter, @association.klass) }
end
rescue => error
FOREST_LOGGER.error "Association Index error: #{error}\n#{format_stacktrace(error)}"
internal_server_error
end
end
|
#update ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/forest_liana/associations_controller.rb', line 38
def update
begin
updater = BelongsToUpdater.new(@resource, @association, params)
updater.perform
if updater.errors
render serializer: nil, json: JSONAPI::Serializer.serialize_errors(
updater.errors), status: 422
else
head :no_content
end
rescue => error
FOREST_LOGGER.error "Association Update error: #{error}\n#{format_stacktrace(error)}"
internal_server_error
end
end
|