8000 raise exception when request parameters not found · udacity/activeadmin_json_editor@4b2d8e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b2d8e9

Browse files
committed
raise exception when request parameters not found
1 parent 4769fd0 commit 4b2d8e9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module ActiveAdmin
22
module HstoreEditor
3-
VERSION = "0.0.1"
3+
VERSION = "0.0.2"
44
end
55
end

lib/activeadmin/resource_dsl.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ module ActiveAdmin
55
class ResourceDSL
66
def hstore_editor
77
before_save do |object,args|
8-
object.class.columns_hash.select {|key,attr| attr.type == :hstore}.keys.each do |key|
9-
object.attributes = {key => JSON.parse(params[object.class.name.underscore][key])} if params[object.class.name.underscore].key? key
8+
request_namespace = object.class.name.underscore
9+
if params.key? request_namespace
10+
object.class.columns_hash.select {|key,attr| attr.type == :hstore}.keys.each do |key|
11+
object.attributes = {key => JSON.parse(params[request_namespace][key])} if params[request_namespace].key? key
12+
end
13+
else
14+
raise ActionController::ParameterMissing, request_namespace
1015
end
1116
end
1217
end

0 commit comments

Comments
 (0)
0