gpt4 book ai didi

ruby-on-rails - 没有成员id的资源路由

转载 作者:行者123 更新时间:2023-12-02 23:50:01 26 4
gpt4 key购买 nike

我开发了一个 Rails 应用程序,并添加了简单的路线:

Name::Application.routes.draw do
resource :categories
end

问题是生成的 URL 中没有成员 id:

$ rake routes
categories POST /categories(.:format) categories#create
new_categories GET /categories/new(.:format) categories#new
edit_categories GET /categories/edit(.:format) categories#edit
GET /categories(.:format) categories#show
PUT /categories(.:format) categories#update
DELETE /categories(.:format) categories#destroy

我使用Rails 3.2.3。我不在应用程序中使用ActiveRecord(但我不知道它是否相关)。我有一个模型 CategoryCategoriesController

可能是什么问题?

最佳答案

您忘记在末尾添加s:

resources :categories

resourcesresource 是不同的东西:resourcesresource

关于ruby-on-rails - 没有成员id的资源路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10992242/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com