Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 Admin Namespace Issue

I'm migrating the majority of my application to the admin namespace and while there are lots of guides related to this, I still can't manage. I've been primarily following this answer, along with any results Google brings up (they all tend to agree). Could somebody please tell me what I'm doing wrong so I don't lose any more sleep?

Here is the error message:

wrong argument type Module (expected Class)

app/controllers/application_controller.rb:1:in `<top (required)>'
app/controllers/admin/admin_controller.rb:1:in `<top (required)>'
app/controllers/admin/home_controller.rb:1:in `<top (required)>'

routes.rb

namespace :admin do 
  root :to => "home#index"

  resources :users
end

admin/admin_controller.rb

class Admin::AdminController < ApplicationController

admin/home_controller.rb

class Admin::HomeController < Admin::AdminController

admin/users_controller.rb

class Admin::UsersController < Admin::AdminController

I'm mostly sure it's something simple to related to the module and controller interaction, so I haven't included any other code. However, I should have found the solution by now and please let me know if any additional code is required.

Thanks.

like image 624
qpingu Avatar asked Sep 10 '10 07:09

qpingu


2 Answers

I encountered the reverse problem "wrong argument type Class (expected Module)" and it turned out there was a helper defined as a Class instead of a Module, so try searching for classes that are inadvertently defined as modules. Like a controller defined as a Module.

like image 91
Russell Avatar answered Nov 19 '22 16:11

Russell


I'd suggest you rename Admin::AdminController to Admin::BaseController.

like image 24
Jonas Bylov Avatar answered Nov 19 '22 16:11

Jonas Bylov