超级简单的目标似乎没有得到很好的记录,我想要一个资源和范围。让路径(& url)帮助器生成范围路径。
即:
scope :info do
resources :publications
end
publications_path => '/info/publications'
publication_path => '/info/publications/:id'
edit_publication_path => '/info/publications/:id/edit'
我甚至可以使用' info _'前缀路径助手,但它们不会被生成。那么使这项工作变得神奇的是什么?
rake路线给出:
Prefix Verb URI Pattern Controller#Action
publications GET /publications(.:format) publications#index
POST /publications(.:format) publications#create
new_publication GET /publications/new(.:format) publications#new
edit_publication GET /publications/:id/edit(.:format) publications#edit
publication GET /publications/:id(.:format) publications#show
PATCH /publications/:id(.:format) publications#update
PUT /publications/:id(.:format) publications#update
DELETE /publications/:id(.:format) publications#destroy
GET /info/publications(.:format) publications#index
POST /info/publications(.:format) publications#create
GET /info/publications/new(.:format) publications#new
GET /info/publications/:id/edit(.:format) publications#edit
GET /info/publications/:id(.:format) publications#show
PATCH /info/publications/:id(.:format) publications#update
PUT /info/publications/:id(.:format) publications#update
DELETE /info/publications/:id(.:format) publications#destroy
答案 0 :(得分:1)
当我看到rake routes
输出时,我只能猜到,但我确定您有resources :publications
重复。
我认为你有
resources :publications
....
scope :info do
resources :publications
end
第一行为出版物生成资源,你得到
publications_path => 'publications'
然后
publications_path
被带走了
/info/publications
没有方法名称