把controller分成group 之后 link_to出现奇怪问题

在Rails项目中,为了更好地组织控制器,创建了额外的文件夹来存放特定类别的控制器。然而,在使用链接导航到这些控制器的动作时遇到了路由问题,尤其是在Internet Explorer浏览器中。
在作一个项目,controller folder 下的各种各样的controller比较多。很乱。
于是新建了几个folder把属于一类的controller 放在一起。
例如就像typo里面那个admin folder一样。
controller(folder) -->welcome_controller.rb
-->admin(folder) --->accounts_controller.rb


可是出现了奇怪的问题。
在一个页面里,比如说有3个link_to生成的link. A B C
其中 A, B 都是link到普通的controller 里面的action.
C 连接到 admin 文件夹下面的controller 里面的action.


<%= link_to 'A', :controller=> 'welcome', :action=>'A'%>
<%= link_to 'B', :controller=> 'welcome', :action=>'B'%>
<%= link_to 'C', :controller=> 'admin/accounts', :action=>'C'%>


问题是:在不点击link C 之前,Link A,B 工作正常。
只要点击了link C 之后,Link A,B 生成的url就变了。
http://localhost:3000/admin/welcome/A

当然,并没有这个page.会出现routing error.
我开始想可能是因为相对路径的问题。

于是解决方法是把link A, B 改成
<%= link_to 'A', :controller=> '../welcome', :action=>'A'%>

之后问题得到初步解决。
无论以什么顺序点击link ABC都没有错误(在firefox 中)。

因为我一直都用firefox + firebug,所以很少用IE。
谁知道在IE 下面问题还不小呢。

问题是:Link C 工作正常。
Link A,B 生成的url就变了。
http://localhost:3000/../welcome/A

此时会出现routing error.


试图找到问题的根源,但是没发现什么特殊的。
不知道大家有没有类似经历,可以给我点启发。
谢谢
[ERROR] [1765200668.587827072, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/left_wheel2base_link/set_parameters] [ERROR] [1765200668.595697897, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/right_wheel2base_link/set_parameters] [ERROR] [1765200668.607726634, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/front_wheel2base_link/set_parameters] [ERROR] [1765200668.618785666, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/back_wheel2base_link/set_parameters] [ERROR] [1765200668.629634551, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/list_controllers] [ERROR] [1765200668.629824071, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/list_controller_types] [ERROR] [1765200668.629847533, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/load_controller] [ERROR] [1765200668.629897291, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/unload_controller] [ERROR] [1765200668.629921218, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/switch_controller] [ERROR] [1765200668.629946964, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/reload_controller_libraries] [INFO] [1765200668.630198451, 257.830000000]: Loaded gazebo_ros_control. [INFO] [1765200668.630524192, 257.830000000]: Loading gazebo_ros_control plugin [INFO] [1765200668.630559722, 257.830000000]: Starting gazebo_ros_control plugin in namespace: / [ERROR] [1765200668.738247589, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/left_wheel2base_link/set_parameters] [INFO] [1765200668.740894, 257.830000]: Controller Spawner: Waiting for service controller_manager/switch_controller [INFO] [1765200668.742798, 257.830000]: Controller Spawner: Waiting for service controller_manager/unload_controller [INFO] [1765200668.743176, 257.830000]: Controller Spawner: Waiting for service controller_manager/switch_controller [INFO] [1765200668.744603, 257.830000]: Loading controller: joint_state_controller [INFO] [1765200668.745332, 257.830000]: Controller Spawner: Waiting for service controller_manager/unload_controller [INFO] [1765200668.747757, 257.830000]: Loading controller: joint_group_eff_controller [INFO] [1765200668.753925, 257.830000]: Loading controller: eff_joint_traj_controller [ERROR] [1765200668.754961647, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/right_wheel2base_link/set_parameters] [INFO] [1765200668.762208, 257.830000]: Controller Spawner: Loaded controllers: joint_group_eff_controller [ERROR] [1765200668.768643455, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/front_wheel2base_link/set_parameters] [ERROR] [1765200668.785391858, 257.830000000]: Tried to advertise a service that is already advertised in this node [/gazebo_ros_control/pid_gains/back_wheel2base_link/set_parameters] [ERROR] [1765200668.808047841, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/list_controllers] [ERROR] [1765200668.808409818, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/list_controller_types] [ERROR] [1765200668.809248185, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/load_controller] [ERROR] [1765200668.809461158, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/unload_controller] [ERROR] [1765200668.809695297, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/switch_controller] [ERROR] [1765200668.810079590, 257.830000000]: Tried to advertise a service that is already advertised in this node [/controller_manager/reload_controller_libraries]
最新发布
12-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值