Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails:路由更新错误_Ruby On Rails_Routes - Fatal编程技术网

Ruby on rails Rails:路由更新错误

Ruby on rails Rails:路由更新错误,ruby-on-rails,routes,Ruby On Rails,Routes,我收到一个路由错误:没有路由匹配“/deccom_tasks/update/1”与{:method=>:put} 我不知道为什么对于通常有效的路由,我会遇到路由错误 路线: map.resources :decom_tasks, :collection => {:sort => :post, :deactivate_task => :get, :reactivate_task => :get} 控制器: def update @task = Task.fi

我收到一个路由错误:没有路由匹配“/deccom_tasks/update/1”与{:method=>:put}

我不知道为什么对于通常有效的路由,我会遇到路由错误

路线:

 map.resources :decom_tasks, :collection => {:sort => :post, :deactivate_task => :get,  :reactivate_task => :get}
控制器:

 def update
    @task = Task.find(params[:id])

    respond_to do |format|
      if @task.update_attributes(params[:task])
        format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @task.errors, :status => :unprocessable_entity }
      end
    end
  end

Mark Thomas是对的,语法错误

这与“任务”是一个模型,然后有一个任务控制器、一个decom_任务控制器和一个com_任务控制器这一事实有关吗?你的错误是“decom”,而你的路线是“decom”,你是在更新之前还是之后收到错误。路由通常是这样的
resource/1/update
,而不是
resource/update/1
不确定语法错误失败的原因。谢谢我不会注意到的。