Skip to content
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

Don't output the whole Rails::Railtie object when a NoMethodError is raised #44495

Merged
merged 1 commit into from
Mar 2, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions railties/lib/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def initialize # :nodoc:
end
end

def inspect # :nodoc:
"#<#{self.class.name}>"
end

def configure(&block) # :nodoc:
instance_eval(&block)
end
Expand Down
13 changes: 13 additions & 0 deletions railties/test/railties/railtie_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,18 @@ class MyTie < Rails::Railtie
Rails.env = original_env
assert_equal(original_env, Rails.env)
end

test "Railtie object isn't output when a NoMethodError is raised" do
class Foo < Rails::Railtie
config.foo = ActiveSupport::OrderedOptions.new
config.foo.greetings = "hello"
end

error = assert_raises(NoMethodError) do
Foo.instance.abc
end

assert_equal("undefined method `abc' for #<RailtiesTest::RailtieTest::Foo>", error.original_message)
end
end
end