如何在发布方法中使用link_to

时间:2018-12-12 11:14:59

标签: javascript ruby-on-rails

我有一个搜索交易并返回结果的URL。这是个电话会议。网址为“ http://192.168.58.129:3000/search”。我有一个称为令牌的列,该列具有值,并且我已经为每个值实现了link_to。单击令牌值时,它应基于令牌进行搜索。当前,它的行为就像get call一样,将所有参数附加到url。我希望它的行为类似于带有相同url(http://192.168.58.129:3000/search)的post,并且将参数附加到form-data而不是url。

`

<table class="table table-condensed table-hover" id="search-result-table" style="margin-left:2%">
        <thead>
        <tr>
          <th>Transaction Id</th>
          <th>Order Id</th>
          <th>Store Id</th>
          <th>Transaction Date</th>
          <th>Transaction Type</th>
          <th>Tender Type</th>
          <th>Token</th>
          <th>Amount</th>
          <th>Currency</th>
          <th>Response </br>Code</th>
        </tr>
        </thead>
        <tbody>
        <% @transactions.each do |transaction| %>
          <tr>
            <td><%= link_to transaction['payment_transaction_id'], details_path(payment_transaction_id: transaction['payment_transaction_id']), {:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %></td>
            <td><%= transaction['payment_session_id'] %></td>
            <td><%= transaction['store_id'] %></td>
            <td><%= transaction['create_timestamp'].in_time_zone(@timezone).strftime('%B %d, %Y - %l:%M %p') %></td>
            <td><%= @transaction_types[transaction['transaction_type']] %></td>
            <td><%= @tenders[transaction['tender_type']][1] %></td>
            <% if (@tenders[transaction['tender_type']][0]).in?(['PLCC', 'GC', 'CC', 'CBCC']) %>
              <td><%= link_to transaction['payment_acct_unique_id'], params.merge(account_id: transaction['payment_acct_unique_id'], show_results: "true",clickAccount:"Y"), id: "act_id" %></td>
            <% else %>
              <td><%= transaction['payment_acct_unique_id'] %></td>
            <% end %>
            <% if show_settlement_type? %>
              <td><%= PaymentsHelper.settlement_amount_with_currency_symbol transaction['transaction_amount'], transaction['iso_currency_code'],transaction['settlement_type'] %></td>
            <% else %>
              <td><%= PaymentsHelper.amount_with_currency_symbol transaction['transaction_amount'], transaction['iso_currency_code'] %></td>
            <% end %>
            <td><%= transaction['iso_currency_code'] %></td>
            <% if transaction['transaction_status'] == ('F') %>
              <td>Payment Service Error</td>
            <% else %>
              <td><%= transaction['response_code'] %></td>
            <% end %>
          </tr>
        <% end %>
        </tbody>
      </table>

`

1 个答案:

答案 0 :(得分:0)

链接按钮

在这里token_id成为查看按钮标签。

  <%= link_to "token_id",transactions_path%>

transactions_path方法,它是不同页面的索引页面的链接,它们是一个   

EX:

   HTTP Verb       Path             Controller#Action   Used for

    1 = GET       /photos            photos#index       display a list of all photos
    2 = GET       /photos/new        photos#new         return an HTML form for creating a new 
        photo
    3 = POST      /photos             photos#create     create a new photo
    4 = GET       /photos/:id         photos#show       display a specific photo
    5 = GET       /photos/:id/edit    photos#edit       return an HTML form for editing a 
        photo
    6 = PATCH/PUT /photos/:id         photos#update     update a specific photo
    7 = DELETE    /photos/:id         photos#destroy    delete a specific photo

Path EX方法:用于不同的操作

   index    articles_path
   new      new_article_path
   show     article_path(:id)
   edit     edit_article_path(:id)
   update   article_path(:id)
   destroy  article_path(:id)