没有路线匹配 {:action=> "show" , :controller=> "tournaments" } 但耙子路线显示锦标赛#show



错误:没有路由匹配 {: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

执行前耙路线显示:

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

我做错了什么?(会随着我解决这个菜鸟问题而更新)

您必须提供要显示的锦标赛实例的 ID。它就在rake routes输出中的:id

如果在执行create操作时发生错误,则可能需要redirect_to tournament_path(@tournament)(或仅redirect_to @tournament)。

最新更新