0

我收到错误消息“:没有路线匹配 [POST]”/subjects/create”

我已将“创建操作”指向“列表”,但列表工作正常,但我无法将新数据发布到我的数据库中。任何人都可以为我指明正确的方向。

Controller:

class SubjectsController < ApplicationController

  def index
    list
    render('list')
  end

  def list
    @subjects = Subject.order(:all)
  end

  def show
     @subject = Subject.find(params[:id])
  end

  def new
   @subject = Subject.new
  end

  def create
    @subject = Subject.new(params[:subject])
   if @subject.save
    redirect_to(:action = 'list') 

   else
       # If save fails, redisplay the form so user can fix problems
      render('new')
    end
   end


end
4

2 回答 2

1

您必须重写它才能读取(您没有正确放入哈希火箭)

redirect_to(:action => 'list')

于 2013-09-19T16:52:16.740 回答
0

No Route Matches错误是因为操作的urlcreate/subjects/create只是POST /subjects

于 2013-09-19T17:18:22.390 回答