我为我的应用程序RailsAdmin安装了,但我无法进入管理面板。授权后我有路由错误:
Routing Error
No route matches [GET] "/admin"
Try running rake routes for more information on available routes.
/config/routes.rb
1.mount RailsAdmin::Engine => '/adminpanel', :as => 'rails_admin'
/config/initializers/rails_admin.rb
1.RailsAdmin.config do |config|
2. config.authorize_with :cancan
3.end
/app/models/ability.rb
1.class Ability
2. include CanCan::Ability
3. def initialize(user)
4. if user.class.to_s == "Admin"
5. can :access, :rails_admin
6. can :manage, :all
7. elsif user.class.to_s == "User"
8. can :manage, :read
9. end
10. end
11.end
我也有Admin模型
/app/models/admin.rb
class Admin < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
end
但是如果我添加我的routes.rb这个:
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
我有循环转发。
请帮我解决这个问题。
答案 0 :(得分:4)
尝试将这两行放在路线的底部:
mount RailsAdmin :: Engine =&gt; '/ adminpanel',:as =&gt; 'rails_admin'
root:to =&gt;重定向( '/ adminpanel')