Skip to content

Commit

Permalink
Only invoke route.source_location if available (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Oct 23, 2024
1 parent ef9403a commit 334b0e7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ruby_lsp/ruby_lsp_rails/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ def resolve_route_info(requirements)
::Rails.application.routes.routes.find { |route| route.requirements == requirements }
end

if route&.source_location
file, _, line = route.source_location.rpartition(":")
source_location = route&.respond_to?(:source_location) && route.source_location

if source_location
file, _, line = source_location.rpartition(":")
body = {
source_location: [::Rails.root.join(file).to_s, line],
verb: route.verb,
Expand Down

0 comments on commit 334b0e7

Please sign in to comment.