我在使用命名空间控制器和路由时遇到了问题。我有以下的命名空间路由。
namespace :institution do
resources :students
end
along with
resources :students, :only => [] do
resources :college_selections, :only =>[:index, :create, :update]
resources :progress, :only => [:index] do
collection {get 'compare'}
end
resources :marks
end
它生成了以下路由。
institution_students GET /institution/students(.:format) {:action=>"index", :controller=>"institution/students"}
POST /institution/students(.:format) {:action=>"create", :controller=>"institution/students"}
new_institution_student GET /institution/students/new(.:format) {:action=>"new", :controller=>"institution/students"}
edit_institution_student GET /institution/students/:id/edit(.:format) {:action=>"edit", :controller=>"institution/students"}
institution_student GET /institution/students/:id(.:format) {:action=>"show", :controller=>"institution/students"}
PUT /institution/students/:id(.:format) {:action=>"update", :controller=>"institution/students"}
DELETE /institution/students/:id(.:format) {:action=>"destroy", :controller=>"institution/students"}
我有一个学生控制器,位于应用程序目录中的机构目录内。它的结构如下:
class Institution::StudentsController < ApplicationController
before_filter :require_login
load_and_authorize_resource
..........
.........
end
现在,当我尝试使用下面所示的link_to辅助方法重定向到学生展示页面时:
<%= link_to "show", institution_student_path(student) %>
然后它显示了一种带有句点(.)的奇怪链接。假设学生ID是100,它生成的路由如下:
institution/students/4.100
这里的4是当前机构ID,我猜测。为什么会生成这样的路由。
当我点击展示链接时,它给我显示错误。
Expected /home/gagan/projects/App_name/app/Institution/students_controller.rb to define StudentsController
我在这里漏掉了什么。
提前感谢。