This project is archived and is in readonly mode.
Dependencies shouldn't swallow errors from required files.
Reported by Marcel Molina | May 1st, 2008 @ 09:11 PM | in 2.1.1
What I did:
I, unknowingly, invoked alias_method in a controller incorrectly by supplying the arguments in the wrong order.
What should have happened:
Usually this would raise an exception saying something like "No such method defined `whatever_your_alias_is_called'".
What happened:
When I ran my tests though, before I'd realized I'd invoked alias_method with the arguments in the wrong order, the exception I was greeted with was:
"Expected foos_controller.rb to defined FoosController". In this case foos_controller.rb does in fact define FoosController, so the exception is entirely misleading.
To find out the actual exception, I added an initializer that required 'application' and then 'foos_controller' to circumvent const_missing auto loading. Then the actual proper exception was raised.
Versions effected:
This behavior is both in 2.0.2 and in edge.
Comments and changes to this ticket
-
Michael Koziarski May 1st, 2008 @ 10:27 PM
- Milestone set to 2.1.1
- Assigned user set to Michael Koziarski
- Title changed from Incorrect alias_method call in controller causes misleading const_missing exception to Dependencies shouldn't swallow errors from required files.
This is frustrating as it masks the true error. I get similar behaviour when I use my 'apple ruby' which doesn't have rmagick installed.
Dependencies shouldn't drop the load error on the ground, it should at the very least show what the original error was, if not raise the original exception
-
Roger May 2nd, 2008 @ 02:28 AM
+1 for wishing this didn't occur. Some work has been done on
http://dev.rubyonrails.org/ticke...
for it [though nothing really satisfactory].
-
Tom Ward May 23rd, 2008 @ 03:54 PM
I've only found one way to reproduce this; In production mode, if an error occurs on the first require of a file, on subsequent requires the error will mask the real problem. I've created a patch that fixes this, but there may well be other ways to make this occur.
If anyone has any other reproducible examples, I'm happy to take a look.
-
Roger May 23rd, 2008 @ 06:01 PM
I believe it happened to me if there was an error in a plugin loading. Like a syntax error in one of the files. The 'real' error message was never output.
In one instance, it was because the plugin filename didn't use rails'ish style syntax [was name acts-as-something instead of acts_as_something]. I'll let you know if I run into it again.
-R
-
Tom Ward May 23rd, 2008 @ 06:10 PM
That specific problem (the plugin-with-hyphenated-name) loading issue was fixed in #24. I got tripped up by that too.
-
Santiago Pastorino October 11th, 2010 @ 12:01 AM
- State changed from new to stale
- Tag set to 2.0-stable, actionpack, activesupport, bug, const_missing, controller, core_ext, dependencies, edge, patch, tests
- Importance changed from to Low
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>