Skip to content

Commit 1e60034

Browse files
authored
Merge pull request #243 from Shopify/avoid_abstract_model_lookup
Avoid inspecting schema info for abstract classes
2 parents 5afb7a3 + e85a41b commit 1e60034

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/ruby_lsp_rails/rack_app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def call(env)
3131
def resolve_database_info_from_model(model_name)
3232
const = ActiveSupport::Inflector.safe_constantize(model_name)
3333

34-
if const && const < ActiveRecord::Base
34+
if const && const < ActiveRecord::Base && !const.abstract_class?
3535
begin
3636
schema_file = ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(const.connection.pool.db_config)
3737
rescue => e

test/ruby_lsp_rails/rack_app_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class RackAppTest < ActionDispatch::IntegrationTest
3535
assert_response(:not_found)
3636
end
3737

38+
test "GET show returns not_found if class is an abstract model" do
39+
get "/ruby_lsp_rails/models/ApplicationRecord"
40+
assert_response(:not_found)
41+
end
42+
3843
test "GET activate returns success to display that server is running" do
3944
get "/ruby_lsp_rails/activate"
4045
assert_response(:success)

0 commit comments

Comments
 (0)