Hola, estoy aprendiendo Ruby y tengo un problema.... y al parecer la informacion que hay al respecto no la he entendido, por lo que agradeceré ayuda... Estoy llamando a un metodo, dentro de este necesito cargar @trabajador, lo hago de la siguiente manera: @trabajador = Trabajador.find(:all, :conditions =>[" persona_id = "+ params[:id]]) el id, viene del .rhtml que carga el método. El error que me aparece es: undefined method `stringify_keys!'' for "240":String entiendo que me está tomando el id correctamente pero que lo lee como un string en vez de un integer... como diablos le digo que es un integer?!?!?! gracias... ________________________________________________________________________________ HI I''m learning Ruby anda have a problem, and it seems that i can''t understand the information abaout it, so i''ll thank your help. i''m calling a method, inside it i need to load @trabajador: @trabajador = Trabajador.find(:all, :conditions =>[" persona_id = "+ params[:id]]) the id, comes from a .rhtml that calls the method, the error I get is: undefined method `stringify_keys!'' for "240":String I think it''s telling me that it was expecting a integer and i send it a string.... how do i tell it to make id an integer??? thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
try this: @trabajador = Trabajador.find(:all, :conditions =>["persona_id = ?", params[:id]]) HTH On 12 Jan., 16:44, Camila <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hola, estoy aprendiendo Ruby y tengo un problema.... y al parecer la > informacion que hay al respecto no la he entendido, por lo que > agradeceré ayuda... > > Estoy llamando a un metodo, dentro de este necesito cargar @trabajador, > lo hago de la siguiente manera: > > @trabajador = Trabajador.find(:all, > :conditions =>[" persona_id = "+ params[:id]]) > > el id, viene del .rhtml que carga el método. > El error que me aparece es: > > undefined method `stringify_keys!'' for "240":String > > entiendo que me está tomando el id correctamente pero que lo lee como un > string en vez de un integer... como diablos le digo que es un > integer?!?!?! > > gracias... > ________________________________________________________________________________ > HI I''m learning Ruby anda have a problem, and it seems that i can''t > understand the information abaout it, so i''ll thank your help. > > i''m calling a method, inside it i need to load @trabajador: > > @trabajador = Trabajador.find(:all, > :conditions =>[" persona_id = "+ params[:id]]) > > the id, comes from a .rhtml that calls the method, the error I get is: > > undefined method `stringify_keys!'' for "240":String > > I think it''s telling me that it was expecting a integer and i send it a > string.... how do i tell it to make id an integer??? > > thanks > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think you need to change.. @trabajador = Trabajador.find(:all, :conditions => [" persona_id = "+ params[:id]]) to.. @trabajador = Trabajador.find(:all, :conditions => [" persona_id = ?", params[:id]]) Camila wrote:> Hola, estoy aprendiendo Ruby y tengo un problema.... y al parecer la > informacion que hay al respecto no la he entendido, por lo que > agradeceré ayuda... > > Estoy llamando a un metodo, dentro de este necesito cargar @trabajador, > lo hago de la siguiente manera: > > @trabajador = Trabajador.find(:all, > :conditions =>[" persona_id = "+ params[:id]]) > > el id, viene del .rhtml que carga el método. > El error que me aparece es: > > undefined method `stringify_keys!'' for "240":String > > entiendo que me está tomando el id correctamente pero que lo lee como un > string en vez de un integer... como diablos le digo que es un > integer?!?!?! > > gracias... > ________________________________________________________________________________ > HI I''m learning Ruby anda have a problem, and it seems that i can''t > understand the information abaout it, so i''ll thank your help. > > i''m calling a method, inside it i need to load @trabajador: > > @trabajador = Trabajador.find(:all, > :conditions =>[" persona_id = "+ params[:id]]) > > the id, comes from a .rhtml that calls the method, the error I get is: > > undefined method `stringify_keys!'' for "240":String > > I think it''s telling me that it was expecting a integer and i send it a > string.... how do i tell it to make id an integer??? > > thanks-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hola Camila. Lo que veo es que tu condicion no esta bien. Trata con: @trabajador = Trabajador.find(:all, :conditions =>["persona_id = ?", params[:id]]) Espero que te ayude. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Seems like I''m late :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks, I was really happy to finally have some answers.... but it didn''t work!!!! I sware.... It keeps giving me the same error. undefined method `stringify_keys!'' for "240":String any other idea?? please!!! -------------------------------------------------------------------------------- Gracias, estaba super contenta de tener algunas respuestas.... pero no funcionó!!! lo juro.... Me sigue dando el mismo error. undefined method `stringify_keys!'' for "240":String alguna otra idea? porfa!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Me podrias mostrar el view de donde haces el post? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I don''t think that line of code is what''s causing the problem. It would help if you could show us more of your code - the whole controller method, the whole view and the stack trace. If there''s too much code, then you should try deleting some code - keep deleting code until the problem goes away, then show us the smallest amount of code that still causes the problem. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ok, here goes the view file:
<%= start_form_tag (:action=> ''update'', :id=>
@persona) %>
<table>
<tr>
<td><h3><strong>Detalles <%=h @persona.nombre %>
<%=h
@persona.apellido1 %></strong></h3</td>
</tr>
<tr>
<td>
<table border = "1">
<tr>
<td>
<p><strong>Nombre Completo:</srong></p>
<p> </p>
</td>
<td>
<%= text_field
(''persona'',''nombre'') %>
</td>
<td>
<%= text_field
(''persona'',"apellido1") %>
</td>
<td width="53" colspan="2" >
<%= text_field
(''persona'',"apellido2") %>
</td>
</tr>
<tr>
<td><strong>RUT/Pasaporte:</strong></td>
<td >
<%=
text_field(''persona'',"rut") %>
</td>
<td><strong>Fecha de
Nacimiento:</strong></td>
<td>
<%= date_select("persona",
"fecha_de_nacimiento")%>
</td>
</tr>
<tr>
<td ><strong>Nacionalidad:</strong></td>
<td >
<%= text_field
(''persona'',"nacionalidad") %>
</td>
<td ><strong>Idiomas:</strong>
<% if @persona.idiomas != nil %>
<% @persona.idiomas.each do |i|%>
<%= i.idioma%>
<%= check_box("idiomas", "idioma",
{:checked =>
"checked"}, "1", "0")%>
<% end%>
<% end%>
<%= select_tag ''idiomas[]'',
options_for_select(Idioma.list_idiomas),{:size
=>3}
%>
</td>
</tr>
<tr>
<td><strong>Correo electrónico:
</strong></td>
</tr>
<tr>
<td><strong>Dirección Postal:
</strong></td>
<td>
<%= text_field
(''persona'',"calle") %>
</td>
<td>
<%= text_field
(''persona'',"numero") %>
</td>
<td>
<%= text_field
(''persona'',"ciudad") %>
</td>
<td>
<%= select ''persona'',
''pais'',Parametros.paises %>
</td>
</tr>
<tr>
<td><strong>Estudios:</strong></td>
<td colspan="3">
</tr>
<% if @persona.estudios != nil%>
<% @persona.estudios.each do |e|%>
<tr>
<td>
<%= link_to ''Eliminar
Estudio'', :action => ''eliminar'', :id =>
@persona %></td>
</td>
<td><strong>Grado:</strong>
<%= e.grado%>
</td>
<td><strong>Institucion:</strong>
<%= e.institucion %>
</td>
<td><strong>Ao:</strong>
<%= e.ano.year
%></td>
</tr>
<%end%>
<%end%>
<td>
<%= link_to ''Agregar
Estudios'',
:action => ''agregar_estudios'', :id => @persona %>
</td>
<div id = agregar_estudios>
<tr>
<td> <strong>Grado:</strong>
<%= text_field (''estudio'',"grado")
%> </td>
<td> <strong>Institucin:</strong>
<%= text_field (''estudio'',"institucion")
%></td>
<td> <strong>Ao:</strong>
<%= date_select ''estudio'', ''ano'',
:start_year => 1940, :discard_day =>
true,:discard_month => true %></p>
</tr>
</div>
<tr>
<td><strong>Empresas:</strong></td>
<td colspan="3">
</tr>
<% if @persona.trabajadores != nil%>
<% @persona.trabajadores.each do
|t|%>
<tr>
<td>
<%= link_to ''Borrar de
Empresa'', :action => ''borrar'', :persona_id =>
@persona, :empresa_id
=>t.empresa.id %>
</td>
<td>
<strong>Empresa:</strong>
<%= t.empresa.razon_social%>
</td>
<td><strong>Cargo:</strong>
<%= text_field
(''trabajadores'',''cargo'') %>
</td>
<%if t.secre != nil%>
<td><strong>Secretaria:</strong>
<%=
t.secre.nombre%>
<%=
t.secre.apellido1%>
<%=
t.secre.apellido2%>
<%=
t.secre.telefono%>
<%= link_to
''Desvincular Secretaria'', :action =>
''desvincular'', :id => @persona %>
</td>
<%else%>
<td><%= link_to
''Vincular Secretaria'', :action =>
''vincular'', :id => @persona %>
</td>
<%end%>
</tr>
<%end%>
<%end%>
</td>
<td>
<%= link_to ''Agregar a
Empresa'',
:action => ''agregar_empresa'', :id => @persona
%></td>
<div id = agregar_empresa
<tr>
<td> <strong>Empresa:</strong>
<%= select_tag ''empresas[]'',
options_for_select(@empresas),{ :multiple =>
true, :size => 5 }
%> </td>
<td> <strong>Cargo:</strong>
<%= text_field (''trabajadores'',"cargo")
%></td>
<td><%= link_to ''Vincular Secretaria'', :action =>
''vincular'', :id =>
@persona %></td>
</tr>
</div>
</td>
</tr>
<tr>
<td><strong>Dirección
Trabajo:</strong></td>
<td>
<%= text_field
(''persona'',"calle_trabajo") %>
</td>
<td>
<%= text_field
(''persona'',"numero_trabajo") %>
</td>
<td>
<%=
text_field(''persona'',"ciudad_trabajo") %>
</td>
<td>
<%= select ''persona'',
''pais_trabajo'',Parametros.paises %>
</td>
</tr>
<tr>
<td><div
align="left"><strong>Área
Interes:</strong></div></td>
<td>
<% if @persona.areas != nil%>
<% @persona.areas.each do |i|%>
<% if i.tipo == "I" %>
<%= i.nombre_area%>
<%= check_box("area",
"nombre_area",
{:checked => "checked"}, "1", "0")%>
<%end%>
<%end%>
<%end%>
<%= select_tag ''areas[]'',
options_for_select(@list_areas_interes),{
:multiple => true, :size => 5 }
%>
<td><strong>Área
Especialización:
</strong></td>
<td>
<% if @persona.areas != nil%>
<% @persona.areas.each do |i|%>
<% if i.tipo == "E" %>
<%= i.nombre_area%>
<%= check_box("area",
"nombre_area",
{:checked => "checked"}, "1", "0")%>
<%end%>
<%end%>
<%end%>
<%= select_tag ''areas[]'',
options_for_select(@list_areas_especializacion),{
:multiple => true, :size => 5 }
%>
</tr>
<tr>
<td><strong>Pertenece a Mapla
<%if @persona.login_mapla != nil %>
<%= check_box("mapla", "login",
{:checked =>
"checked"}, "1", "0")%>
<div id = pertenece_mapla
<td colspan="2"><div
align="right">
<td><strong>Nombre de
Usuario:</strong></div>
<%= text_field
(''persona'',"login_mapla") %>
</td>
<td><div
align="right"><strong>Password:</strong></div>
<%= text_field
(''persona'',"password_mapla") %>
</td>
</div>
</tr>
<%else%>
<%= check_box("mapla",
"login", {}, "1",
"0")%>
<%end%>
<tr>
<td><strong>Origen de la
Información:</strong></td>
<td>
<%= text_field
(''persona'',"origen_dato") %>
</td>
<%if @persona.sin_rut = "true" or
@persona.mail_rebotado = "true" or @persona.telefono_malo =
"true" or
@persona.gest_eventos = "true"%>
<td class="alert">
<strong>Falta
Revisión</strong>
<%= check_box
(''en_seguimiento'', ''revision'',
{:checked => ''checked''},"1", "0"
)%></td>
<%end%>
</tr>
<tr>
<td><strong>Observaciones:</strong></td>
<td colspan="3">
<%=
text_area(''persona'',"observaciones") %>
</td>
</tr>
<tr>
<td><%= link_to ''Enviar Mail'', :action
=> ''escribir_mail'' ,
:id => @persona %></td>
<td colspan="2"><a
href="#">Eliminar</a></td>
<td colspan="4"><%= submit_tag
"Guardar"%></td>
</tr>
<tr>
<td colspan="7"></td>
</tr>
<tr>
<td colspan="7"> </td>
</tr>
</table>
<%= end_form_tag %>
<%= link_to ''Atras'', :action => ''list''
%>
The submit_tag Guardar calls the following controller method:
def update # Metodo utilizado para guardar cambios de personas.
(Editar) Camila Bolaos 5/1/07
@persona = Persona.find(params[:id])
@idioma = Idioma.find_all
@trabajador = Trabajador.find(:all, :conditions => [" persona_id =
?",params[:id]])
if @persona.update_attributes(params[:id])
flash[:notice] = ''El contacto ha sido modificado
exitosamente''
redirect_to :action => ''list'', :id =>
@persona
else
flash[:notice] = ''El contacto NO ha sido modificado, revise la
informacin''
redirect_to :action => ''show'', :id=> @persona
end
end
The error:
undefined method `stringify_keys!'' for "106":String
... Thanks for helping......
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I think this line is the problem: if @persona.update_attributes(params[:id]) It looks like you''re passing a String (the id) to the method, but it wants a hash of attribute => value pairs. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Snow Man wrote:> I think this line is the problem: > > if @persona.update_attributes(params[:id]) > > It looks like you''re passing a String (the id) to the method, but it > wants a hash of attribute => value pairs.Thanks Snow Man.... I change it to if @persona.update_attributes(params[:persona]) and it works!!!!! I''m really glad. Of course I''ll have some other problems with ruby so we''ll be in touch... Chika -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---