Hi i have the following problem. I followed the screen cast to create
complex forms from railscats so i create a partial view for my
equipments list, so the client can add several different equipments, I
also made another view in case looking for the equipment inside the
select box. When i choose a equipment from the view (find_equipment) i
created there is no problem when there is only one equipment inside
the client form, but when I another equipment and I try to select it
from the select view (find_equipment) it does not update the select
box it should, it update the first select box.
I have a similar problem with observe_field, it should update the
properties for a certain product, but it only update the first select
list the other lists are not updated.
Here is the source code:
_equipment_services.html.erb
<div class="equipment">
<% fields_for "voip[equipments_services_attributes]
[]",equipment_services do |e|%>
<p class="titulo">Información Equipos</p>
<p>
Activo Fijo
<
%=e.select("equipment_id",Equipment.find(:all,:conditions=>"estado=6",:order=>"numero_activo_fijo").collect{|
p|[p.numero_activo
_fijo, p.id]},:index=>nil)%>
<% if equipment_services.new_record? %>
<%="Estado Activo"%>
<%=e.hidden_field("estado",:value=>6)
%>
<%= link_to_function "Eliminar",
"this.up(''.equipment'').remove()" %>
<%else%>
<=% link_to_function "Eliminar",
"mark_for_destroy(this,''.contact'')" %>
<%= e.hidden_field(:id,:index=>nil) %>
<%= "Estado" %>
<%e.select("estado",Code.find(:first,
:conditions=>["id=5"]).elements.collect{|
p| [p.descripcion,p.id]},:index=>nil) %>
<%e.hidden_field(:should_destroy,:index=>nil,
:class=>"should_destroy")
%>
<%end%>
<%=link_to "Crear Nuevo
Equipo",add_equipment_equipment_path,:popup =>
["Agregar_Nuevo_Equipo","height=600, width=700"]%>
<%= link_to "Buscar Equipos",
{:action=>"find_equipment",
:controller=>"show_select"}, :popup =>
["Show_Equipment","height=60
0, width=700"]%>
</p>
<%end %>
</div>
javascript function
function set_value(id,value)
{
opener.document.getElementById(id).value=value;
window.close();
}
find_equipment.html.erb
<table>
<tr>
<% form_tag find_equipment_show_select_path, :method=>"get"
do%>
<td>Buscar Usuario:</td>
<td><%=select_tag "busqueda","<option
value=''1''>Modelo</
option><option value=''2''
selected=''true''>Número Activo Fijo</op
tion><option value=''3''>Número
Serie</option><option
value=''4''>Dirección
MAC</option>"%>
<td><%=text_field_tag :search, params[:search]%></td>
<td colspan=3><%=submit_tag "Buscar",
:name=>nil%></td>
<%end%>
</tr>
<tr>
<th>Modelo</th>
<th>Marca</th>
<th>Activo Fijo</th>
<th>Número de serie</th>
<th> Tipo Equipo </th>
</tr>
<%
switch=false
for equipment in @equips
%>
<tr class="<%= if switch
"TRPAR"
else
"TRIMPAR"
end %>
<% switch=!switch %>">
<td><%=equipment.modelo%></td>
<td><%=Code.getDescripcion(equipment.marca)%></td>
<td><
%=link_to_function("#{equipment.numero_activo_fijo}","set_value(''voip_equipments_services_attributes__equipment_id'',''#{equi
pment.id}'')")%></td>
<td><%=equipment.numero_serie%></td>
<td><%=Code.getDescripcion(equipment.code_id)%></td>
</tr>
<% end %>
</table>
Can anyone help me please? i''m kind of lost here
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---