Skip to content

Commit 8fcee36

Browse files
authored
Merge pull request #1304 from benebrice/fix--link-builder-on-root-engine
Fix link builder on root engine
2 parents b8c57d5 + 318bf85 commit 8fcee36

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ env:
66
- "RAILS_VERSION=5.1.7"
77
- "RAILS_VERSION=5.2.3"
88
- "RAILS_VERSION=6.0.0"
9-
# - "RAILS_VERSION=master"
109
rvm:
1110
- 2.3.8
1211
- 2.4.7

lib/jsonapi/link_builder.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def engine?
2929
def primary_resources_url
3030
if @primary_resource_klass._routed
3131
primary_resources_path = resources_path(primary_resource_klass)
32-
@primary_resources_url_cached ||= "#{ base_url }#{ engine_mount_point }#{ primary_resources_path }"
32+
@primary_resources_url_cached ||= "#{ base_url }#{ serialized_engine_mount_point }#{ primary_resources_path }"
3333
else
3434
if JSONAPI.configuration.warn_on_missing_routes && !@primary_resource_klass._warned_missing_route
3535
warn "primary_resources_url for #{@primary_resource_klass} could not be generated"
@@ -139,7 +139,11 @@ def resource_path(source)
139139
end
140140

141141
def resource_url(source)
142-
"#{ base_url }#{ engine_mount_point }#{ resource_path(source) }"
142+
"#{ base_url }#{ serialized_engine_mount_point }#{ resource_path(source) }"
143+
end
144+
145+
def serialized_engine_mount_point
146+
engine_mount_point == "/" ? "" : engine_mount_point
143147
end
144148

145149
def route_for_relationship(relationship)

0 commit comments

Comments
 (0)