Is there anything wrong with this code? <% for tipo in @roteiro.roteiro_tipos -%> <td><%= text_field ''tipo[]'', ''titulo'' %></td> <td><%= text_field ''tipo[]'', ''preco'' %></td> <td><%= text_field ''tipo[]'', ''lugares'' %></td> <tr> </tr> <% end %> I always get a NoMethodError complaining that I have a nil object. This is part of a edit form. Thanks! -- Erick Sasse _______________________________________________________ Promoo Yahoo! Acesso Grtis: a cada hora navegada voc acumula cupons e concorre a mais de 500 prmios! Participe! http://yahoo.fbiz.com.br/
> You''ll want to use this instead: > > for @tipo in @roteiro.roteiro_tipos > ... > > The helper methods have no way of accessing local variables (such as > tipo) so they assume instance variables instead.Thanks! It did the trick! -- Erick Sasse www.ericksasse.com.br _______________________________________________________ Promoo Yahoo! Acesso Grtis: a cada hora navegada voc acumula cupons e concorre a mais de 500 prmios! Participe! http://yahoo.fbiz.com.br/
On Oct 7, 2005, at 5:21 PM, Erick Sasse wrote:> Is there anything wrong with this code? > > <% > for tipo in @roteiro.roteiro_tipos > -%> > <td><%= text_field ''tipo[]'', ''titulo'' %></td> > <td><%= text_field ''tipo[]'', ''preco'' %></td> > <td><%= text_field ''tipo[]'', ''lugares'' %></td> > <tr> > </tr> > <% end %> > > I always get a NoMethodError complaining that I have a nil object. > This is part of a edit form. >You''ll want to use this instead: for @tipo in @roteiro.roteiro_tipos ... The helper methods have no way of accessing local variables (such as tipo) so they assume instance variables instead. Duane Johnson (canadaduane)