重命名导轨路线参数到ID
在我的utaes.rb
文件中,我有以下资源
resources :classrooms, only: [:index, :new, :create] do
resources :students, only: [:index, :edit, :update], controller: 'students' do
get :honor
end
end
我的荣誉路线变为/classrooms/:classroom_id/students/:students_id/nonor(。:格式)
> 但是我想将student_id
替换为id
,以便我可以在学生控制器中轻松使用它。
理想路线是/classrooms/:Classroom_id/students/:ID/Honor(。格式)
In my routes.rb
file, I have the following resources
resources :classrooms, only: [:index, :new, :create] do
resources :students, only: [:index, :edit, :update], controller: 'students' do
get :honor
end
end
My honor route becomes /classrooms/:classroom_id/students/:students_id/honor(.:format)
but I want to replace student_id
to id
so that I can easily use it in the students controllers.
Ideal route is /classrooms/:classroom_id/students/:id/honor(.:format)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做到这一点是会员路线。这样
或
You can do that specifying it's a member route. this way
or