Skip to content

Commit

Permalink
Merge pull request rails#51620 from joshuay03/encourage-lease-connect…
Browse files Browse the repository at this point in the history
…ion-on-model-inspect-no-connection

Encourage `#lease_connection` over `#connection` on AR model `#inspect` without connection
  • Loading branch information
byroot committed Apr 22, 2024
2 parents 82054e8 + 7861476 commit edbe467
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/core.rb
Expand Up @@ -354,7 +354,7 @@ def inspect # :nodoc:
elsif abstract_class?
"#{super}(abstract)"
elsif !connected?
"#{super} (call '#{super}.connection' to establish a connection)"
"#{super} (call '#{super}.lease_connection' to establish a connection)"
elsif table_exists?
attr_list = attribute_types.map { |name, type| "#{name}: #{type.type}" } * ", "
"#{super}(#{attr_list})"
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/invalid_connection_test.rb
Expand Up @@ -20,7 +20,7 @@ def setup
end

test "inspect on Model class does not raise" do
assert_equal "#{Bird.name} (call '#{Bird.name}.connection' to establish a connection)", Bird.inspect
assert_equal "#{Bird.name} (call '#{Bird.name}.lease_connection' to establish a connection)", Bird.inspect
end
end
end

0 comments on commit edbe467

Please sign in to comment.