Marcial
Marcial

Reputation: 17

link_to render de the view of destiny before action rails

Thanks for your atenttion, when i pass the pointer over the link, this link_to render the view of destiny but not redirect to the view, only in the terminar appear the GET action, i think this was happen because i was installed bootstrap, but i uninstalled and i have the same problem, i don't know why happen this. This happen in all my links. I have Rails 7.1.3.

example of the reder in the terminal

Started GET "/medico" for ::1 at 2024-04-06 10:57:28 -0600
Processing by AppointmentsController#panel_medico as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3 LIMIT 1
  ↳ app/controllers/application_controller.rb:8:in `set_current_user'
  Rendering layout /home/programador/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/turbo-rails-2.0.5/app/views/layouts/turbo_rails/frame.html.erb
  Rendering appointments/panel_medico.html.erb within layouts/turbo_rails/frame
  Appointment Load (0.2ms)  SELECT `appointments`.* FROM `appointments` WHERE (medical_session_id = '6')
  ↳ app/views/appointments/_sidebar_appointments.erb:5
  Rendered appointments/_sidebar_appointment.erb (Duration: 0.2ms | Allocations: 122)
  Rendered appointments/_sidebar_appointment.erb (Duration: 0.1ms | Allocations: 108)
  Rendered appointments/_sidebar_appointment.erb (Duration: 0.1ms | Allocations: 108)
  Rendered appointments/_sidebar_appointment.erb (Duration: 0.1ms | Allocations: 108)
  Rendered appointments/_sidebar_appointment.erb (Duration: 0.1ms | Allocations: 108)
  Rendered appointments/_sidebar_appointments.erb (Duration: 1.8ms | Allocations: 1409)
  Rendered appointments/panel_medico.html.erb within layouts/turbo_rails/frame (Duration: 1.9ms | Allocations: 1478)
  Rendered layout /home/programador/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/turbo-rails-2.0.5/app/views/layouts/turbo_rails/frame.html.erb (Duration: 2.0ms | Allocations: 1583)
Completed 200 OK in 4ms (Views: 2.0ms | ActiveRecord: 0.5ms | Allocations: 2479)

In my main view, i have this code of the erb.

<div class="container">
<div class='row'>
    <div class="col-md-3" style="height: 30em; overflow: auto">
        <%= render partial: 'sidebar_appointments',
        locals: { 
            appointments: @appointments_createds, sesion_consulta: @session_consulta
        } %>
    </div>
    
    <div class="col-md-9">
        <% if params[:appointment_selected].present? %>
            <form class="row g-3">
                <div class="col-md-12 d-flex justify-content-center">
                    <div>
                        <label for="inputZip" class="form-label">Servicios adquiridos</label>
                        <div style="width: 30em; height: 10em; overflow: auto;">
                            <table class="table table-hover" cellSpacing="0" cellPadding="1" border="1">
                                <thead style="position: -webkit-sticky; position: sticky; top: 0;">
                                    <tr>
                                        <th>Name</th>
                                        <th>Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <%= render partial: 'service_acquired',
                                        locals: { 
                                            servicesList: @servicesList
                                        }
                                    %>
                                </tbody>
                            </table>
                        </div>
                        <br/>
                        
                        <%= link_to modal_services_path(appointment_id: params[:appointment_selected]), data: { turbo_frame: "modal_services"} do %>
                            <button type="button" class="btn btn-outline-primary">
                                Add Service
                            </button>
                        <% end %>
                    </div>
                </div>

                <div class="col-md-12">
                    <div class="form-floating">
                        <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea" onChange={onChange}></textarea>
                        <label for="floatingTextarea">Comentarios</label>
                    </div>
                </div>

                <div class="col-12"></div>
                <div class="row justify-content-end">
                    <div class="col-md-5"></div>
                    <div class="col-md-5"></div>
                    <div class="col-md-2">
                        <button type="submit" class="btn btn-success">Finalizar</button>
                    </div>
                </div>
            </form>
            <%= turbo_frame_tag "modal_services" %>
            <!-- modal-html: 5:41 / js: 9:59-->
            <!-- aparecer: class = show, style = "display: block;" 'aria-modal'= "true" role= "dialog"-->
            <!-- ocultar: class quitar show, style = "display: none;", quitar role, quitar aria-modal, 'aria-hidden' = "true" -->
            <%-# render partial: 'service_modal', locals: { servicesList: @servicesList, sesion_consulta: @session_consulta } %>
        <% end %>
    </div>
</div>

In the partial _sidebar_appointments

 <%= turbo_stream_from "appointments-medico#{@session_consulta}" %>

<div data-controller="room_appointments-medico<%= @session_consulta %>" data-appointment-current-session-id-value="<%= @session_consulta %>">
    <div id="appointments">
        <% appointments.each do |appointment| %>
            <%= render partial: 'sidebar_appointment', locals: { appointment: appointment, session_consulta: @session_consulta } %>
        <% end %>
    </div>
</div>

And the partial with the link_to

<%= turbo_frame_tag appointment do %>
    <%= link_to medico_path( appointment_selected: appointment.id ), class: "nav-link", 'data-turbo-frame': '_top' do %>
        <div class="card <%=
                appointment.status == 0 ? 'border-primary' 
                : appointment.status == 1 ? 'border-secondary'
                : appointment.status == 2 ? 'border-success'
                : "" %> mb-3 card-width" >
            <div class="card-header" >Ficha: <%= "#{appointment.clave} #{appointment.consecutivo}" %></div>
            <div
                class="card-body <%=
                appointment.status == 0 ? 'border-primary' 
                : appointment.status == 1 ? 'border-secondary'
                : appointment.status == 2 ? 'border-success'
                : "" %>">
                <div class='row'>
                    <div class='col-md-8'>
                        <h5 class="card-title"><%= appointment.nombre_paciente %></h5>
                    </div>
                    <div class='col-md-4'>
                        <h6 class="card-title text-light text-center rounded <%=
                            appointment.status == 0 ? 'bg-danger'
                            : appointment.status == 1 ? 'bg-primary' 
                            : appointment.status == 2 ? 'bg-info'
                            : appointment.status == 3 ? 'bg-success'
                            : appointment.status == 4 ? 'bg-secondary'
                            : "" %>">
                            <%= appointment.status == 0 ? 'Canceled'
                            : appointment.status == 1 ? 'Stand By' 
                            : appointment.status == 2 ? ''
                            : appointment.status == 3 ? ''
                            : appointment.status == 4 ? 'Finish'
                            : "" %>
                        </h6>
                    </div>
                </div>
            </div>
        </div>
    <% end %>
<% end %>

Upvotes: 0

Views: 43

Answers (0)

Related Questions