轨道上的红宝石没有路线匹配{:action =>“show”,:controller =>“pythonhowto”}

时间:2014-02-10 00:21:53

标签: ruby-on-rails ruby-on-rails-3.2

当我浏览到我的pythonhowto / new page时,我收到路由错误。错误是没有路由匹配{:action =>“show”,:controller =>“pythonhowto”}

我的控制器

class PythonhowtoController < ApplicationController
 def index
    @pythonhowto = Post.all
   end
def show
    @post = Post.find(params[:id])
   end
def new
    @post = Post.new
  end   
  def create
  end

我的pythonhowto / new是

<%= form_for(@post, :url =>{:action=>"show", :controller=>"pythonhowto"}) do |f| %>

的routes.rb

R::Application.routes.draw do

资源:pythonhowto

1 个答案:

答案 0 :(得分:1)

首先,您可能不应post使用show方法。但是,要解决当前问题,您需要执行form_for(..., :url => your_route_path_helper)。你可以通过rake routes找到这个。找到路径路径帮助程序名称后,只需使用helper_name_pathhelper_name_url,如果需要传递这些函数,它们都会接受查询参数函数。

相关问题