Ruby on rails 如何使用Haml和Rails中的复选框发送表中记录的ID

Ruby on rails 如何使用Haml和Rails中的复选框发送表中记录的ID,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我的Rails 1.9应用程序有一个问题,我希望发送与我正在迭代和显示的模型表相关的ID 我正确设置了复选框\u标签,并试图将整个表格封装在表单\u标签中,以便将ID发送回控制器,以便我可以在不同的视图中编辑它们 代码中与此相关的“我的路线”部分是: routes.rb: match '/workflow_queue/index', :to => 'WorkflowQueue#index', :as => 'workflow_queue' match '/workflow_queue

我的Rails 1.9应用程序有一个问题,我希望发送与我正在迭代和显示的模型表相关的ID

我正确设置了
复选框\u标签
,并试图将整个表格封装在
表单\u标签
中,以便将ID发送回控制器,以便我可以在不同的视图中编辑它们

代码中与此相关的“我的路线”部分是:

routes.rb:

match '/workflow_queue/index', :to => 'WorkflowQueue#index', :as => 'workflow_queue'
match '/workflow_queue/import_tendays', :to => 'WorkflowQueue#import', :as => 'workflow_queue_import'
match '/workflow_queue/import_finish', :to => 'WorkflowQueue#import_finish', :as => 'workflow_queue_import_finish'
match '/workflow_queue/delete', :to => 'WorkflowQueue#delete', :as => 'workflow_queue_delete'
resources :workflowqueue do
  member do
    post 'edit_multiple'    
  end
end
根据文档中的说明,routes文件应该创建一个带有
edit\u multiple\u workflowqueue\u path
的路径,它似乎在这样做,因为当我去显示包含此代码的部分时

_form_workflows.html.haml

=form_tag  edit_multiple_workflowqueue_path  do

  %thead
    %tr

      %th= 'Entity_Type'
      %th= 'Entity_ID'
      %th= 'Workflow ID'
      %th= 'Message'
      %th= ''
      %th= ''


  %tbody
    - for wf in @workflowtasks
      %tr

        %td= wf.entity_type
        %td= wf.entity_id
        %td= wf.workflow_id
        %td= wf.message
        %td= check_box_tag "wf_ids[]", wf.id
        %td= link_to "Destroy", workflow_queue_delete_path(wf)
=submit_tag "Edit Checked"
我一直在犯错误

No route matches {:action=>"edit_multiple", :controller=>"workflowqueue"}
这对我来说没有太大意义,因为在我的控制器代码中,它明确定义了一个
edit\u multiple
操作,并且路由中的控制器名称与控制器处理的每个其他操作使用的名称完全相同,这意味着如果我执行
rake routes
,控制器的名称显示在Rails自动创建的“new”、“edit”和“delete”方法中

我真的不明白为什么它在控制器中找不到方法。控制器代码为:

class WorkflowQueueController < ApplicationController

  def index
    @workflows = WorkflowQueue.all

    @title = 'Workflow Queues'

  end

  def import
    @title = 'Import Tenday Notices'
    @form_errors = []
  end

  def import_finish
    @title = 'Imported Tendays'
    if params[:xml]
      @start_time = Time.now

      @filename = params[:xml].original_filename

      errors_and_imports = WorkflowQueue.read_tenday_xml(params[:xml].read)
      @errors = errors_and_imports[:errors]
      @extra_imports = errors_and_imports[:extra_imports]

      @form_errors = []

      @workflowtasks = WorkflowQueue.all
    else
      @form_errors = [ 'Please select a file to upload.' ]
      render 'import'
    end
  end

  def edit_multiple
    @workflows = WorkflowQueue.all
    render 'index'
  end

  def delete
    url_string = request.url
    id = url_string.split('.')[3]
    workflow_to_be_deleted = WorkflowQueue.find(id.to_i).destroy

    @workflowtasks = WorkflowQueue.all
    @title = 'Imported Tendays'
    @form_errors = []
    @errors = []
  end

end
class WorkflowQueueController

edit\u multiple
中的代码是一次性代码,只是为了查看是否正在调用该方法

由于“编辑多个”路由是“workflowqueue”的成员,您需要传递workflowqueue id:

edit_multiple_workflowqueue_path(@workflowqueue)