gpt4 book ai didi

ruby-on-rails - rails_admin 路由错误

转载 作者:数据小太阳 更新时间:2023-10-29 08:38:33 24 4
gpt4 key购买 nike

我为我的应用程序安装了 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'

我有循环转发。

请帮我解决这个问题。

最佳答案

尝试将这两行放在你的路线的底部:

mount RailsAdmin::Engine => '/adminpanel', :as => 'rails_admin'
root :to => redirect('/adminpanel')

关于ruby-on-rails - rails_admin 路由错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19334792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com