Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.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 - Fatal编程技术网

Ruby on rails 单击一行转到Rails中的另一个路径

Ruby on rails 单击一行转到Rails中的另一个路径,ruby-on-rails,Ruby On Rails,我的HAML文件中有以下代码: %table.table-base.table-striped.table-hover{:id => "work-list-table"} %thead %tr %th{'no-sort' => 'true'}= t('worklist.work_list') %th{'no-sort' => 'true'}= t('worklist.number_of_work_ite

我的HAML文件中有以下代码:

    %table.table-base.table-striped.table-hover{:id => "work-list-table"}
      %thead
        %tr
          %th{'no-sort' => 'true'}= t('worklist.work_list')
          %th{'no-sort' => 'true'}= t('worklist.number_of_work_items')
      %tbody
        -for x in [1,2,3]
          %tr{:id => x,href: duplicate_claims_work_lists_path, :style => "cursor:pointer"}
            %td
              %ul.custom-ul
                %li
                  %h4
                    = "hello"
            %td
              %ul.custom-ul
                %h4
                  = "3"
这将创建包含列“hello”和“3”的3行。我假设我可以单击3行中的任意一行来复制\u声明\u工作\u列表\u路径,但它仍保留在页面上,并且根本没有路径。下面是一些类似的代码,当单击该行时,这些代码会正确显示路径:

%table.table-base.table-striped.table-hover{:id => "remittance-table"}
  %thead
    %tr
      %th{:type => 'payer'}= t('payers.payer')
      %th.data-type-number{'sort-type' => 'totalPayments'}= t('remittances.total_remittance')

  %tbody
    - @remittances.each do |remittance|
      %tr{:id => remittance.id,href: edit_remittance_path(remittance), :style => "cursor:pointer"}
        %td= remittance.payer.name
        -remit = remittance.total_payments.to_i >= 0 ? "pos" : "neg"

你知道为什么我在单击行时无法将第一个代码示例放到path任意位置吗`重复的"声明""工作""列出"路径"是有效的,因为我有一个菜单子栏带我去那里

您正在
元素上设置
href
属性,链接不是这样工作的。使用
帮助器创建链接:

%tbody
  - for x in [1,2,3]
    %tr{id: x}
      %td
        = link_to duplicate_claims_work_lists_path

老实说,我真的不知道第二个示例为什么有效。

不需要使用哈希设置非动态id,可以使用
%table.table base.table striped.table hover#work list table
,也不需要
=
对于非动态内容,您可以删除
%h4=“hello”的它们(带引号)
%h4=“3”
,最后,您应该避免混合使用旧的哈希样式
{:key=>value}
和新的哈希样式
{key:value}