File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -1127,7 +1127,7 @@ array. Consider this `ActiveRecord` relationship:
1127
1127
{% highlight ruby %}
1128
1128
# app/models/employee.rb
1129
1129
has_many : positions
1130
- has_one : current_position , -> { where(created_at: : desc ) }
1130
+ has_one : current_position , -> { where(created_at: : desc ) }, class_name: 'Position'
1131
1131
1132
1132
Employee.includes('current_position').to_a
1133
1133
@@ -1144,7 +1144,7 @@ The same thing happens in Graphiti:
1144
1144
{% highlight ruby %}
1145
1145
# app/resources/employee_resource.rb
1146
1146
has_many : positions
1147
- has_one : current_position do
1147
+ has_one : current_position , resource: PositionResource do
1148
1148
params do |hash|
1149
1149
hash[ : sort ] = '-created_at'
1150
1150
end
@@ -1169,7 +1169,7 @@ where a value of `1` meant "most recent":
1169
1169
{% highlight ruby %}
1170
1170
# app/models/employee.rb
1171
1171
has_many : positions
1172
- has_one : current_position , -> { where(historical_index: 1) }
1172
+ has_one : current_position , -> { where(historical_index: 1) }, class_name: 'Position'
1173
1173
1174
1174
Employee.includes('current_position').to_a
1175
1175
You can’t perform that action at this time.
0 commit comments