Skip to content

Avoid inspecting schema info for abstract classes #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ruby_lsp_rails/rack_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def call(env)
def resolve_database_info_from_model(model_name)
const = ActiveSupport::Inflector.safe_constantize(model_name)

if const && const < ActiveRecord::Base
if const && const < ActiveRecord::Base && !const.abstract_class?
begin
schema_file = ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(const.connection.pool.db_config)
rescue => e
Expand Down
5 changes: 5 additions & 0 deletions test/ruby_lsp_rails/rack_app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class RackAppTest < ActionDispatch::IntegrationTest
assert_response(:not_found)
end

test "GET show returns not_found if class is an abstract model" do
get "/ruby_lsp_rails/models/ApplicationRecord"
assert_response(:not_found)
end

test "GET activate returns success to display that server is running" do
get "/ruby_lsp_rails/activate"
assert_response(:success)
Expand Down