错误:没有路线匹配{:action=>“显示”,:controller=>“锦标赛”}
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
endroutes.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..。
我做错了什么?(将随着我完成这一期“新报”的进展而更新)
发布于 2013-10-19 13:48:28
您必须提供您希望显示的锦标赛实例的ID。它就像:id一样出现在rake routes输出中。
如果在执行create操作时出现错误,则可能需要redirect_to tournament_path(@tournament) (或仅redirect_to @tournament)。
https://stackoverflow.com/questions/19466701
复制相似问题