elocal_api_support 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/elocal_api_support/actions/update.rb +12 -5
- data/lib/elocal_api_support/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12310ae89e5df33b87cb16516d5347a6d674c294
|
4
|
+
data.tar.gz: 9c3b01f7b39cb561fb860a888e4d1b7f0ee17377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 291c2c2c1beac59b296f477eca2fb43f93c66fbae008c53da0afc661f9bc3fdef816ebedeaa6fa41cd95a77b2a447ada4e94d15948c8f395b8cc69a328f19f10
|
7
|
+
data.tar.gz: 2ab22283710e09c9252271ad66c2d3e3c6cc97f2e505d3de3831d2f66c86661cb12eaa66dd7b4d7a29a55c2667a40adcd9ce2d8cddfd88a2e6d56843a5eb430b
|
@@ -1,23 +1,30 @@
|
|
1
1
|
module ElocalApiSupport
|
2
2
|
module Actions
|
3
3
|
module Update
|
4
|
+
DEFAULT_IGNORED_PARAMETERS = %w(id created_at updated_at).freeze
|
5
|
+
|
4
6
|
def update
|
5
|
-
params.permit!
|
6
7
|
if lookup_object.update_attributes(parameters_available_for_update)
|
7
8
|
render json: lookup_object
|
8
9
|
else
|
10
|
+
Rails.logger.info { "There was an issue updating model #{lookup_object}" }
|
11
|
+
Rails.logger.debug { "Error details #{lookup_object.errors.to_xml}" }
|
9
12
|
render json: { errors: lookup_object.errors }, status: 422
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
13
16
|
private
|
14
17
|
|
15
|
-
def
|
16
|
-
|
18
|
+
def parameters_to_ignore_from_update
|
19
|
+
DEFAULT_IGNORED_PARAMETERS
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
20
|
-
|
22
|
+
def updatable_parameter_names
|
23
|
+
associated_model.columns.map(&:name) - parameters_to_ignore_from_update
|
24
|
+
end
|
25
|
+
|
26
|
+
def parameters_available_for_update
|
27
|
+
params[associated_model_name].permit(*updatable_parameter_names)
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|