File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 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:
11271127{% highlight ruby %}
11281128# app/models/employee.rb
11291129has_many : positions
1130- has_one : current_position , -> { where(created_at: : desc ) }
1130+ has_one : current_position , -> { where(created_at: : desc ) }, class_name: 'Position'
11311131
11321132Employee.includes('current_position').to_a
11331133
@@ -1144,7 +1144,7 @@ The same thing happens in Graphiti:
11441144{% highlight ruby %}
11451145# app/resources/employee_resource.rb
11461146has_many : positions
1147- has_one : current_position do
1147+ has_one : current_position , resource: PositionResource do
11481148 params do |hash|
11491149 hash[ : sort ] = '-created_at'
11501150 end
@@ -1169,7 +1169,7 @@ where a value of `1` meant "most recent":
11691169{% highlight ruby %}
11701170# app/models/employee.rb
11711171has_many : positions
1172- has_one : current_position , -> { where(historical_index: 1) }
1172+ has_one : current_position , -> { where(historical_index: 1) }, class_name: 'Position'
11731173
11741174Employee.includes('current_position').to_a
11751175
You can’t perform that action at this time.
0 commit comments