Skip to content

Commit

Permalink
Encourage #lease_connection over #connection on AR model `#inspec…
Browse files Browse the repository at this point in the history
…t` without connection
  • Loading branch information
joshuay03 committed Apr 21, 2024
1 parent 284baa1 commit 7861476
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 7861476

Please sign in to comment.