2013-10-19 45 views
0

錯誤:沒有路線匹配{:action =>「show」,:controller =>「錦標賽「}沒有路線匹配{:action =>「show」,:controller =>「tournaments」}但是耙路線顯示錦標賽#show

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 

執行搜索路線顯示:

...

tournament GET /tournaments/:id(.:format)  tournaments#show 

...

我在做什麼錯? (將隨着我在這個noob問題上的進展而更新)

回答

2

您必須提供您希望顯示的錦標賽實例的ID。它正好在rake routes輸出:id

如果在執行create操作時發生錯誤,您可能需要redirect_to tournament_path(@tournament)(或者只是redirect_to @tournament)。

相關問題