как использовать link_to с методом post - PullRequest
0 голосов
/ 12 декабря 2018

У меня есть URL, который ищет транзакции и возвращает результат.Это почтовый звонок.URL-адрес: "http://192.168.58.129:3000/search". У меня есть столбец с именем token, в котором есть значения, и я реализовал link_to для каждого значения. При щелчке по значению токена он должен искать на основе токена. В настоящее время он ведет себя как вызов get,добавление всех параметров к URL. Я хочу, чтобы он вел себя как сообщение с тем же URL (http://192.168.58.129:3000/search) с параметрами, добавленными к данным формы, а не к 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 голосов
/ 12 декабря 2018

кнопка ссылки

здесь 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

Путь 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)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...