Ruby on Rails Sunday, April 1, 2012

Rails 3.1.3

I am trying to create an administrator page. 'User' table has a field,
admin:boolean, then user having 'admin=true' can only access it, as you
can imagine.

But accessing

http://localhost:3000/admin/user

gives an error,

uninitialized constant UserController

I have 'controllers/admin/admin_application_controller.rb'

class Admin::AdminApplicationController < ApplicationController
before_filter :admin_login_required

def admin_login_required
if @current_user.admin
return true
end
redirect_to :controller => "/"
return false
end
end

also, 'controllers/admin/user_controller.rb'

class Admin::UserController < Admin::AdminApplicationController
active_scaffold :user
end

I am guessing that the problem is routes.rb, which is

Takibou::Application.routes.draw do
devise_for :users
resources :projects
root :to => 'projects#index'
match ':controller(/:action(/:id))(.:format)'

scope 'admin' do #HERE!!!!!
resources :user
end
end


Could anyone help me for the error?

soichi

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment