[rspec-users] i've been in activeadmin hell...
jko170 at gmail.com
Fri Apr 6 19:53:21 UTC 2012
On Apr 6, 2012, at 1:40 PM, Patrick J. Collins wrote:
>> On Apr 6, 2012, at 11:21 AM, Patrick J. Collins wrote:
>>> ... Changing the filename app/admin/users.rb to app/admin/wtfs.rb
>>> makes this error go away... so--- wtfs indeed!
> On Fri, 6 Apr 2012, Justin Ko wrote:
>> I'm pretty sure this is an issue with how Rails autoloads things, I've run into it a few times. Checkout this post:
> Well what doesn't make sense to me, is that I would expect having a file
> called wtfs.rb should give a similar error expecting "Wtfs" to be
> defined... But it doesn't..
In Ruby, if you define a namespace class without defining the top-level class first, you'll get an error:
1.9.3p125 :001 > class Foo::Bar; end
NameError: uninitialized constant Foo
from /Users/justinko/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'
So as you can see from your backtrace, the error is generating from confirmations_controller.rb, which makes sense because it has "class Users::ConfirmationsController".
If you look further up the backtrace, you'll see activesupport trying to handle that error with its `load_missing_constant` method. I assume it "searched" for a file named "users", because the constant was named "Users". WTF doesn't cause an error, because activesupport doesn't look for it.
Try renaming your namespace from "Users" to "User", which is a more appropriate name IMO.
> Patrick J. Collins
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users