11< div style ="margin-left: 20px; border-left: 2px solid var(--border-color); padding-left: 15px; margin-top: 12px; margin-bottom: 12px; ">
22 < p style ="margin: 0; font-size: 0.85em; color: var(--text-secundario); display: flex; align-items: center; gap: 6px; ">
3- <% if comentario . usuario . foto_base64 . present? %>
4- < img src ="<%= comentario . usuario . foto_base64 %> " style ="width: 16px; height: 16px; border-radius: 50%; object-fit: cover; ">
3+ <% if comentario . fantasma? %>
4+ < span > ?</ span >
5+ < strong style ="color: var(--text-secundario); "> Anonimo</ strong >
56 <% else %>
6- < span > 👤</ span >
7+ <% if comentario . usuario &.foto_base64 . present? %>
8+ < img src ="<%= comentario . usuario . foto_base64 %> " style ="width: 16px; height: 16px; border-radius: 50%; object-fit: cover; ">
9+ <% else %>
10+ < span > 👤</ span >
11+ <% end %>
12+ < strong style ="color: #fff; "> <%= comentario . usuario &.nombre || "Anónimo" %> </ strong >
713 <% end %>
8- < strong style =" color: #fff; " > <%= comentario . usuario . nombre %> </ strong > | Votos: < span style ="color: var(--accent); font-weight: bold; "> <%= comentario . votos %> </ span >
14+ | Votos: < span style ="color: var(--accent); font-weight: bold; "> <%= comentario . votos %> </ span >
915 </ p >
1016
11- < p style ="margin: 6px 0; color: var(--text-principal); font-size: 0.95em; white-space: pre-line; "> <%= comentario . cuerpo %> </ p >
17+ < p style ="margin: 6px 0; color: var(--text-principal); font-size: 0.95em; white-space: pre-line; <%= 'font-style: italic; color: var(--text-secundario);' if comentario . fantasma? %> "> <%= comentario . cuerpo %> </ p >
1218
1319 < div style ="display: flex; gap: 12px; font-size: 0.8em; align-items: center; ">
14- <%= link_to "▲" , votar_arriba_preguntum_comentario_path ( comentario . preguntum , comentario ) , method : :patch , style : "color: var(--accent); font-weight: bold;" %>
15- <%= link_to "▼" , votar_abajo_preguntum_comentario_path ( comentario . preguntum , comentario ) , method : :patch , style : "color: #da3633; font-weight: bold;" %>
20+ <%= button_to "▲" , votar_arriba_preguntum_comentario_path ( comentario . preguntum , comentario ) , method : :patch , style : "background: none; border: none; cursor: pointer; color: var(--accent); font-weight: bold; padding: 0 ;" %>
21+ <%= button_to "▼" , votar_abajo_preguntum_comentario_path ( comentario . preguntum , comentario ) , method : :patch , style : "background: none; border: none; cursor: pointer; color: #da3633; font-weight: bold; padding: 0 ;" %>
1622
17- < details style ="display: inline; ">
18- < summary style ="cursor: pointer; color: var(--text-secundario); list-style: none; "> Responder</ summary >
19- <%= form_with url : preguntum_comentarios_path ( comentario . preguntum ) , local : true , style : "margin-top: 8px; min-width: 250px;" do |f | %>
20- <%= hidden_field_tag :comentario_padre_id , comentario . id %>
21- <%= f . text_area :cuerpo , rows : 2 , placeholder : "Escribe tu respuesta pública..." , required : true , style : "margin-bottom: 8px;" %> < br >
22- <%= f . submit "Responder" , style : "padding: 6px 12px; font-size: 0.85em;" %>
23+ <% unless comentario . fantasma? %>
24+ < details style ="display: inline; ">
25+ < summary style ="cursor: pointer; color: var(--text-secundario); list-style: none; "> Responder</ summary >
26+ <%= form_with url : preguntum_comentarios_path ( comentario . preguntum ) , local : true , style : "margin-top: 8px; min-width: 250px;" do |f | %>
27+ <%= hidden_field_tag :comentario_padre_id , comentario . id %>
28+ <%= f . text_area :cuerpo , rows : 2 , placeholder : "Escribe tu respuesta pública..." , required : true , style : "margin-bottom: 8px;" %> < br >
29+ <%= f . submit "Responder" , style : "padding: 6px 12px; font-size: 0.85em;" %>
30+ <% end %>
31+ </ details >
32+
33+ <%# CONTROL DE ACCIONES DE AUTOR: Editar y Borrar %>
34+ <% if usuario_actual && comentario . usuario_id == usuario_actual . id %>
35+ < span style ="color: var(--border-color); "> |</ span >
36+
37+ <%# Formulario Inline para editar usando el array polimórfico [pregunta, comentario] %>
38+ < details style ="display: inline; ">
39+ < summary style ="cursor: pointer; color: var(--accent); list-style: none; "> Editar</ summary >
40+ <%# SOLUCIÓN POLIMÓRFICA: Rails deduce la ruta automáticamente %>
41+ <%= form_with model : [ comentario . preguntum , comentario ] , method : :patch , local : true , style : "margin-top: 8px; min-width: 250px;" do |f | %>
42+ <%= f . text_area :cuerpo , value : comentario . cuerpo , rows : 2 , required : true , style : "margin-bottom: 8px;" %> < br >
43+ <%= f . submit "Guardar Cambios" , style : "padding: 6px 12px; font-size: 0.85em;" %>
44+ <% end %>
45+ </ details >
46+
47+ < span style ="color: var(--border-color); "> |</ span >
48+ <%# Botón para borrar usando la misma solución polimórfica %>
49+ <%= button_to "Borrar" , [ comentario . preguntum , comentario ] , method : :delete , data : { confirm : "¿Seguro que deseas eliminar este comentario?" } , style : "background: none; border: none; cursor: pointer; color: #da3633; padding: 0; font-family: inherit; font-size: inherit;" %>
2350 <% end %>
24- </ details >
51+ <% end % >
2552 </ div >
2653
2754 <% if comentario . hijos . any? %>
2855 <%= render partial : 'comentarios/comentario' , collection : comentario . hijos . order ( votos : :desc , created_at : :asc ) %>
2956 <% end %>
30- </ div >
57+ </ div >
0 commit comments