ITeye博客

使用 rails_admin + cancan 时,发生 No route matches {:controller=>"home"}

tiroc · 2013-04-12 09:32 · Ruby on Rails · 编程语言 · Markdown

囧 rails_admin 官方的 wiki 中已经写了,是我自作主张没看。。。。。 https://github.com/sferik/rails_admin/wiki/CanCan#handle-unauthorized-access


弄了个小项目,后台使用 rails_admin,好久没用这个东西了,现在发展的还真不错!

权限控制使用 cancan,在 ApplicationController 中写上:


  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, alert: exception.message
  end

然后以普通权限的用户进入网站后台,发生错误:

Routing Error

No route matches {:controller=>"home"}

Try running rake routes for more information on available routes.

按说这个时候应该返回到首页,并提示权限不够的。

几番搜索之后,答案在这: http://stackoverflow.com/a/8924188/960494

可耻的我 StackOverflow 的 reputation 不够,不能 vote,憾事,憾事。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。