rest_rails 1.1.5 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bbf6117c22067039afe036aba247c3f20ac9ba930e3d1140349e70aaaf67d01
|
4
|
+
data.tar.gz: 88f538adec8d1fd23e67462434fd0845b511777313e30291937c6f89910a51a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9edb560515e507117c98bab2b05d483ab0a0e9455ead8bc820a9ab6d66d608d62dd8c6e8f640e8cac4f7d3e02a2943edb8ce258136659bb999c4a8173478a254
|
7
|
+
data.tar.gz: d8758148705b26ce8d1dbcf5cce5c55d501ddc326e417b2a19c65aab8165ddf7994a32bb949de530cd307fdfc5d3185f1af14a10064df937eaf5c601c93a70b2
|
@@ -16,7 +16,7 @@ module RestRails
|
|
16
16
|
base_query = p_hash.blank? ? @model.all : @model.where(p_hash)
|
17
17
|
|
18
18
|
@objects = base_query.order(:id).limit(ppage).offset(off)
|
19
|
-
@objects.map
|
19
|
+
@objects = @objects.map{|x| standardize_json(x) }
|
20
20
|
|
21
21
|
render json: {code: 200, objects: @objects, count: @objects.count, total: @model.count}
|
22
22
|
end
|
@@ -69,10 +69,12 @@ module RestRails
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def nested_attributes_for(ar_object)
|
72
|
-
|
72
|
+
ar_model = ar_object.class
|
73
|
+
tables = ar_model.nested_attributes_options.keys
|
73
74
|
|
74
75
|
tables.map do |x|
|
75
|
-
|
76
|
+
nested_model = ar_model.reflect_on_association(x).klass
|
77
|
+
cols = nested_model.column_names.map(&:to_sym)
|
76
78
|
key = "#{x}_attributes".to_sym
|
77
79
|
cols << :_destroy
|
78
80
|
|
@@ -80,18 +82,14 @@ module RestRails
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
83
|
-
|
84
|
-
|
85
85
|
# ==========================================================================
|
86
86
|
# OTHER HELPERS
|
87
87
|
# ==========================================================================
|
88
88
|
|
89
89
|
def model_for(table_name)
|
90
|
-
|
91
|
-
"schema_migrations", "ar_internal_metadata"]
|
92
|
-
tables = ActiveRecord::Base.connection.tables.reject{ |x| ignored.include?(x) }
|
90
|
+
tables = ActiveRecord::Base.descendants.reject(&:abstract_class).index_by(&:table_name)
|
93
91
|
|
94
|
-
raise RestRails::Error.new "Table '#{table_name}' does not exist in your database!" unless tables.include?(table_name)
|
92
|
+
raise RestRails::Error.new "Table '#{table_name}' does not exist in your database!" unless tables.keys.include?(table_name)
|
95
93
|
|
96
94
|
# Take the tablename, and make the Model of the relative table_name
|
97
95
|
table_name.classify.constantize # "users" => User
|
data/config/routes.rb
CHANGED
@@ -4,6 +4,7 @@ RestRails::Engine.routes.draw do
|
|
4
4
|
|
5
5
|
get '/:table_name/:id' => 'data#show', as: 'data_show'
|
6
6
|
patch '/:table_name/:id' => 'data#update'
|
7
|
+
put '/:table_name/:id' => 'data#update'
|
7
8
|
delete '/:table_name/:id' => 'data#destroy', as: 'data_destroy'
|
8
9
|
|
9
10
|
post '/:table_name/:id/attach/:attachment_name' => 'data#attach'
|
data/lib/rest_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rivas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|