Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Dependencies shouldn't swallow errors from required files.

#87

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.

Reported by Marcel Molina · May 1st, 2008 @ 09:11 PM

State: stale
Milestone: 2.1.1
Assigned to: Michael Koziarski Michael Koziarski
Importance: Low

Activity

  1. Michael Koziarski
  2. Michael Koziarski
    Michael Koziarski
    • 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

    May 1st, 2008 @ 10:27 PM

  3. Roger
    Roger

    +1 for wishing this didn't occur. Some work has been done on

    http://dev.rubyonrails.org/ticke...

    for it [though nothing really satisfactory].

    May 2nd, 2008 @ 02:28 AM

  4. Tom Ward
    Tom Ward

    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.

    May 23rd, 2008 @ 03:54 PM

  5. Roger
    Roger

    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

    May 23rd, 2008 @ 06:01 PM

  6. Tom Ward
    Tom Ward

    That specific problem (the plugin-with-hyphenated-name) loading issue was fixed in #24 Prevent Dependencies.new_constants_in cleanup code masking real error when co.... I got tripped up by that too.

    May 23rd, 2008 @ 06:10 PM

  7. Santiago Pastorino
    Santiago Pastorino
    • 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

    October 11th, 2010 @ 12:01 AM