首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有路线匹配{:action=>“显示”,:controller=>“锦标赛”},但rake路线显示tournaments#show

没有路线匹配{:action=>“显示”,:controller=>“锦标赛”},但rake路线显示tournaments#show
EN

Stack Overflow用户
提问于 2013-10-19 13:46:19
回答 1查看 421关注 0票数 0

错误:没有路线匹配{:action=>“显示”,:controller=>“锦标赛”}

代码语言:javascript
复制
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:

代码语言:javascript
复制
  resources :tournaments do 
    member do
      get "results"
    end

    resources :opportunities do
      member do
        get 'rate'
      end
    end
  end

执行rake路线显示:

..。

代码语言:javascript
复制
tournament GET    /tournaments/:id(.:format)       tournaments#show

..。

我做错了什么?(将随着我完成这一期“新报”的进展而更新)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-19 13:48:28

您必须提供您希望显示的锦标赛实例的ID。它就像:id一样出现在rake routes输出中。

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19466701

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档