Rails Require Weirdness

Can someone please explain why adding require 'xmlmarkup' to the beginning of application_helper.rb causes the file to not be loaded? Instead you get this error message in the log, ApplicationController: missing default helper path application_helper, as if the file simply did not exist. And, of course, a failure to render any pages that make use of any of the application helper methods, since they are not available.

I strongly suspect that it is related to the auto-loading magic that Rails has but it is not clear to me exactly how it is related. I do know, now, at least, that it is unnecessary to explicitly require this file in order to use Builder::XmlMarkup, but it seems like it should be allowed. After all, requiring the file seems like the most obvious choice if you know Ruby better than Rails. The non-obviousness of this problem combined with the fact that none of the error messages generated specify the actual problem make this problem a bit annoying.

1 thought on “Rails Require Weirdness

  1. I am not certain what is causing your problem, but if you are in development ‘mode’ (the default I think) then try using require_dependency instead of require. Can’t make it worse at least :-)

Comments are closed.