为什么我的铁轨路线有些偏离? [英] Why is my rails route is a bit off?

查看:98
本文介绍了为什么我的铁轨路线有些偏离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的根路线

root :to => 'home#index'

这是我的家庭控制器,如果我访问 http:// localhost:3000 / 一切正常,我点击了适当的家庭控制器和索引操作。然后,我安装了这个gem rails_admin ,但是当我访问 http:// localhost:3000时, / admin 我在应用程序控制器中找到了方法

which is for my home controller and if i visit http://localhost:3000/ all works great i hit the proper home controller and index action. I then installed this gem rails_admin But when i visit http://localhost:3000/admin i hit the method in my application controller

rescue_from CanCan::AccessDenied do |exception|
  redirect_to root_path, :alert => exception.message
end

并得到此错误,现在我怎么可能路由错误...任何想法

and get this error, how is it possible that now i have a routing error...any idea

Routing Error

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


推荐答案

我认为问题在于,rails_admin引擎中没有HomeController,它拥有自己的路由,并且以某种方式停止了(因为引擎中没有这样的控制器)。我会尝试使用:

I think the problem lies in that there's no HomeController in the rails_admin engine which has it's own routing, and somehow it stops there (because there's no such controller in the engine). I'd try using:

redirect_to root_url

甚至是这个

redirect_to '/'

这最后一种方法意味着Rails不必尝试通过调用URL来找出路径,并且在使用Engines时可能更安全

This last way means rails doesn't have to try to figure out the path by calling URL for, and might be safer when working with Engines.

这篇关于为什么我的铁轨路线有些偏离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆