1
我很困惑Rails 3资源路由。我有以下我routes.rb
什么时候应该在Rails中创建命名路线?
resources :dungeons, only: [ :index, :destroy, :create, :update, :show ]
线当我检查什么命名路由与rake routes
创造,我得到:
dungeons GET /dungeons(.:format) dungeons#index
POST /dungeons(.:format) dungeons#create
dungeon GET /dungeons/:id(.:format) dungeons#show
PUT /dungeons/:id(.:format) dungeons#update
DELETE /dungeons/:id(.:format) dungeons#destroy
为什么有只与一个HTTP GET方法的路线命名路由?如果我想创建一个销毁行动的链接,我不得不使用类似{ :action => 'destroy', :method => :delete, :id => dungeon.id }
而不是简单的destroy_dungeon_path(dungeon)
。我的routes.rb
有什么问题吗?
谢谢迈克尔,我已经多次阅读链接,但不知何故错过了HTTP方法thingy。 –
试试这= link_to“我的链接”,dungeon_path(id),方法::删除 –
@GeraudMathe:是的,这是做的工作:-) –