I did this in test.rb
:
def some_method
p "First definition"
end
def some_method
p "Second definition"
end
some_method
When I call ruby test.rb
, it prints Second definition
(expected)
When I call ruby -w test.rb
, it prints Second definition
(expected) and prints a warning test.rb:5: warning: method redefined; discarding old some_method
Is there a way to enable those warnings in Rails? (and print the warning to the console/log file)
Why I would like to enable warnings: For example if I inadvertently re-define a method in a controller, then I would be aware of the problem by looking at the warning printed to the console/log file. See here for an example.