rest_rails 1.1.4 → 1.1.8

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: e8b6432f33edd284597125d028daf6a2d3e8d99fb3be32f5942a24661f1de68d
4
- data.tar.gz: d044c206a90b679b02afbb91d93394be1b0023fe19468555a047215d5e13eadf
3
+ metadata.gz: 200b9569c1dae09a67cb8f6b545c045bc0a204881cb9b28534aa7c6cb3e43eb4
4
+ data.tar.gz: 88dedfe22ac6693bef11331a85a7b3f884b709f26ed54beadf596bd57de4be34
5
5
  SHA512:
6
- metadata.gz: bced5b85c30350d6df6457470a17ef4ad771fcc081512f214e304c1112b8c836ba7339ce508afa576ebc813de7c785574c35bf8379e11923ce20ca85aeee4851
7
- data.tar.gz: 59ded15da6a4ee151440615f94c70e410bd043375f25b8be32165e2afdd6fb9e995b76b4fe5b37b77ac21d36d67b593415e2507b577a792daa4a4ab9019929d9
6
+ metadata.gz: 8727d575c1e4996f3008d14f21d0431b3c0b55ea7a55b267c6a530ec0dbfcf72507a03927de11b4cea082514a23b0f43604714d721eb732dbf61e669aca3c1be
7
+ data.tar.gz: 3a5a4b9375a2a4fd6de6fc89743b92a822199914c33797b1d4acce859c5a53f7de057d48e65f853b7e0a9ac254d9bc17f026ffa820d3c05a9d5d23e7a8a5c4b1
@@ -9,6 +9,10 @@ module RestRails
9
9
 
10
10
  private
11
11
 
12
+ def verify_authenticity_token
13
+ true
14
+ end
15
+
12
16
  def not_found(exception)
13
17
  if RestRails.debug
14
18
  raise exception
@@ -2,7 +2,7 @@ require 'json'
2
2
  module RestRails
3
3
  class DataController < ::ApplicationController
4
4
  include ApplicationHelper
5
- skip_before_action :verify_authenticity_token, if: -> {self.respond_to?("verify_authenticity_token")}
5
+ # skip_before_action :verify_authenticity_token, if: -> {self.respond_to?("verify_authenticity_token")}
6
6
  before_action :verify_table_permissions!, only: [:create, :update, :destroy, :attach, :unattach]
7
7
  before_action :set_model
8
8
  before_action :set_object, only: [:show, :update, :destroy, :fetch_column, :attach, :unattach]
@@ -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!{|x| standardize_json(x) }
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
- tables = ar_object.class.nested_attributes_options.keys
72
+ ar_model = ar_object.class
73
+ tables = ar_model.nested_attributes_options.keys
73
74
 
74
75
  tables.map do |x|
75
- cols = x.to_s.classify.constantize.column_names.map(&:to_sym)
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,8 +82,6 @@ module RestRails
80
82
  end
81
83
  end
82
84
 
83
-
84
-
85
85
  # ==========================================================================
86
86
  # OTHER HELPERS
87
87
  # ==========================================================================
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'
@@ -1,3 +1,3 @@
1
1
  module RestRails
2
- VERSION = '1.1.4'
2
+ VERSION = '1.1.8'
3
3
  end
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
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Rivas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2021-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails