Skip to content

Commit 9c4569c

Browse files
committed
Fix polymorphic associations
1 parent 40b46cd commit 9c4569c

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.6.0
4+
5+
- Fixes transforming polymorphic relations through `read_param`
6+
- Update all dependencies
7+
38
## 0.5.0
49

510
- Update collection call in `index` and `administrate` dependency

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
administrate-base_controller (0.5.0)
4+
administrate-base_controller (0.6.0)
55

66
GEM
77
remote: https://rubygems.org/
@@ -189,7 +189,7 @@ DEPENDENCIES
189189
administrate-base_controller!
190190
bundler (~> 2.0)
191191
minitest (~> 5.0)
192-
rails
192+
rails (~> 6.0)
193193
rake (~> 13.0)
194194

195195
BUNDLED WITH

administrate-base_controller.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ Gem::Specification.new do |spec|
3838
spec.add_development_dependency 'bundler', '~> 2.0'
3939
spec.add_development_dependency 'minitest', '~> 5.0'
4040
spec.add_development_dependency 'rake', '~> 13.0'
41-
spec.add_development_dependency 'rails'
41+
spec.add_development_dependency 'rails', '~> 6.0'
4242
end

lib/administrate/base_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ def resource_params
102102
end
103103

104104
def read_param(_, data)
105-
if data.is_a?(ActionController::Parameters) && data[:type]
106-
return read_param_value(data)
105+
if data.is_a?(Hash) && data[:type]
106+
if data[:type] == Administrate::Field::Polymorphic.to_s
107+
return GlobalID::Locator.locate(data[:value])
108+
end
107109
end
108110

109111
data
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Administrate
22
module BaseController
3-
VERSION = '0.5.0'
3+
VERSION = '0.6.0'
44
end
55
end

0 commit comments

Comments
 (0)