Rails - uninitialized constant Admin
I'm working to build an admin console for my app.
I added admin_controller.rb ... class AdminController < ApplicationController
I then added resources :admin
to my routes.
I then added a model which is empty, as there is no DB table for the admin views, it's just reports off other tables:
class Admin < ActiveRecord::Base
end
The admin console won't have 开发者_Go百科a model in the db.
When I try to access the /admin view I get the error:
Access denied on index Admin(Table doesn't exist)
If you inherit from ActiveRecord::Base
you're going to need a database table. If you don't need a database table then don't inherit from ActiveRecord::Base
.
If you want to be able to use some of the features from active record, like validations or callbacks, you can include the modules you need. Here's a good write up that will explain everything:
http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
精彩评论