vendredi 25 janvier 2019

Rails link_to tag do not change the url in the browser

I am using Rails 5 with ruby 2.4
I have few statements wirtten on the view page with the link_to tag when I click on the link_to tag the it redirect me to the next page but don the change the URL this is very strange for me here is my view page.

<div class="container">
  <%= render "shared/breadcrumb" %>
  <%= render "shared/back_button" %>
  <h2>Cader</h2>
  <div id="data_conversion_request">
    <div class="row">
      <% unless @job.nil? %>
        <div class="row">
          <div class="col-md-12">
            <table class="table">
              <thead>
              <tr>
                <th scope="col" colspan="4">
                  You have checked out a job on <%= @job.bucket.created_at.strftime("%m/%d/%Y %I:%M %p") %>
                </th>
              </tr>
              </thead>
              <tbody>
              <tr>
                <th scope="row">Job ID</th>
                <th><%= @job.id %></th>
              </tr>
              <tr>
                <th scope="row">CLient</th>
                <th><%= @job.user.full_name %><th>
              </tr>
              <tr>
                <th scope="row">Email</th>
                <th><%= @job.user.email %><th>
              </tr>
              <tr>
                <th scope="row">Client Company</th>
                <th><%= @job.user.address.company_institute_name %></th>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
        <div class="row">
          <div class="col-md4"></div>
          <div class="col-md4"></div>
        </div>
        <div class="row">
          <div class="col-md4"></div>
          <div class="col-md4"></div>
        </div>
        <div class="row">
          <div class="col-md-2 col-md-offset-1" style="background:lightgreen">
            <h3>Job tools</h3>
          </div>
        </div>
      <% end %>
      <ul class="list-group">
        <% if @job.nil? %>
          <li class="list-group-item">
            <%= link_to 'Check out job', cader_available_job_path, class: '', title: 'check in an available job', data: {toggle: 'tooltip'} %>
          </li>
        <% else %>
          <li class="list-group-item">
            <%= link_to 'Check in a job', cader_check_in_job_path(:job_id => @job.id), class: 'btn btn-link', title: 'checkin job', data: {toggle: 'tooltip'} %>
          </li>
          <li class="list-group-item">
            <%= link_to 'Release a job', cader_release_job_path(:job_id => @job.id), class: 'btn btn-link', title: 'release job', data: {toggle: 'tooltip'} %>
          </li>
          <li class="list-group-item">
            <!--            <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>-->
            <%= button_tag 'Download files', class: "btn btn-link", onclick: "job_files(#{@job.id})", data: {toggle: 'modal', target: '#files'} %>
            <%#= link_to 'Download files', cader_downloads_path(:job_id => @check_cader[0].job_id), class: '', title: '', data: {toggle: 'tooltip'} %>
          </li>
          <li class="list-group-item">
            <%= button_tag 'History', class: "btn btn-link", onclick: "history(#{@job.id})", data: {toggle: 'modal', target: '#history'} %>
            <%#= link_to 'History', cader_history_path(:job_id => @check_cader[0].job_id),class: '', title: 'Job History', data: {toggle: 'tooltip'} %>
          </li>
        <% end %>
      </ul>
      <div> System Tools</div>
      <ul>
        <!--        <li class="list-group-item">-->
        <%#= link_to 'Customer profile', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
        <!--        </li>-->
        <!--        <li class="list-group-item">-->
        <%#= link_to 'Messages', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
        <!--        </li>-->
        <!--        <li class="list-group-item">-->
        <%#= link_to 'Queue Status', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
        <!--        </li>-->
        <li class="list-group-item">
          <%= link_to 'Job folder', cader_job_folder_path, class: '', title: '', data: {toggle: 'tooltip'} %>
        </li>
        <!--        <li class="list-group-item">-->
        <%#= link_to 'Reset timer', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
        <!--        </li>-->
        <!--        <li class="list-group-item">-->
        <%#= link_to 'Recent Jobs', 'javascript:void(0)', class: '', title: '', data: {toggle: 'tooltip'} %>
        <!--        </li>-->
      </ul>
    </div>
  </div>
  <div id="checklist_data_conversion" style="display: none;"></div>
</div>

<!-- Modal -->
<div id="files" class="modal fade" role="dialog">
</div>

<!-- Modal 2 -->
<div id="history" class="modal fade" role="dialog">
</div>


<script type="text/javascript">

    <% unless @job.nil? %>

    function history(id) {
        // console.log('Reached');
        $.ajax({
            type: "GET",
            url: "<%= cader_history_path(:job_id => @job.id) %>",
            data: {"id": id},
            dataType: 'html',
            success: function (data) {
                $('#history').html(data);
                // console.log('success');
            },
        });
    }

    function job_files(id) {
        // console.log('Reached');
        $.ajax({
            type: "GET",
            url: "<%= cader_downloads_path(:job_id => @job.id) %>",
            data: {"id": id},
            dataType: 'html',
            success: function (data) {
                $('#files').html(data);
                // console.log('success');
            },
        });
    }

    <% end %>

</script>

But the same link_to tag is working fine for rest of the pages in the application, please correct when is written incorrect inside the page or is there any other way to write the link_to tag.

Aucun commentaire:

Enregistrer un commentaire