File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -506,10 +506,12 @@ def attributes(*attrs)
506
506
end
507
507
end
508
508
509
- def attribute ( attr , options = { } )
509
+ def attribute ( attribute_name , options = { } )
510
+ attr = attribute_name . to_sym
511
+
510
512
check_reserved_attribute_name ( attr )
511
513
512
- if ( attr . to_sym == :id ) && ( options [ :format ] . nil? )
514
+ if ( attr == :id ) && ( options [ :format ] . nil? )
513
515
ActiveSupport ::Deprecation . warn ( 'Id without format is no longer supported. Please remove ids from attributes, or specify a format.' )
514
516
end
515
517
@@ -903,7 +905,8 @@ def _add_relationship(klass, *attrs)
903
905
options = attrs . extract_options!
904
906
options [ :parent_resource ] = self
905
907
906
- attrs . each do |relationship_name |
908
+ attrs . each do |name |
909
+ relationship_name = name . to_sym
907
910
check_reserved_relationship_name ( relationship_name )
908
911
check_duplicate_relationship_name ( relationship_name )
909
912
Original file line number Diff line number Diff line change @@ -1470,12 +1470,12 @@ def records_for(rel_name)
1470
1470
end
1471
1471
1472
1472
class BookResource < JSONAPI ::Resource
1473
- attribute : title
1473
+ attribute " title"
1474
1474
attributes :isbn , :banned
1475
1475
1476
- has_many : authors
1476
+ has_many " authors"
1477
1477
1478
- has_many : book_comments, relation_name : -> ( options = { } ) {
1478
+ has_many " book_comments" , relation_name : -> ( options = { } ) {
1479
1479
context = options [ :context ]
1480
1480
current_user = context ? context [ :current_user ] : nil
1481
1481
@@ -1486,7 +1486,7 @@ class BookResource < JSONAPI::Resource
1486
1486
end
1487
1487
} , reflect : true
1488
1488
1489
- has_many : aliased_comments, class_name : 'BookComments' , relation_name : :approved_book_comments
1489
+ has_many " aliased_comments" , class_name : 'BookComments' , relation_name : :approved_book_comments
1490
1490
1491
1491
filter :book_comments ,
1492
1492
apply : -> ( records , value , options ) {
You can’t perform that action at this time.
0 commit comments