错误:没有路线匹配{:action =>“show”,:controller =>“tournaments”}
class TournamentsController < ApplicationController
def new
@tournament = Tournament.new
end
def create
@tournament = Tournament.new(params[:tournament].permit(:description))
if @tournament.save
#flash[:notice] = 'tournament was successfully created.'
#set up links
redirect_to :action => 'show'
else
render :action => 'new'
end
end
def show
@tournament = Tournament.first
end
end
routes.rb中:
resources :tournaments do
member do
get "results"
end
resources :opportunities do
member do
get 'rate'
end
end
end
执行rake路线显示:
...
tournament GET /tournaments/:id(.:format) tournaments#show
...
我做错了什么? (随着我在这个菜鸟问题上的进展,将会更新)
答案 0 :(得分:2)
您必须提供您希望展示的锦标赛实例的ID。它就在:id
输出中的rake routes
处。
如果您执行create
操作时发生错误,则可能需要redirect_to tournament_path(@tournament)
(或仅redirect_to @tournament
)。