# Problems with fields\_for

**URL:** <https://www.ruby-forum.com/t/problems-with-fields-for/81970>\
**Category:** Rails\
**Created:** [January 16, 2007, 5:17pm UTC](https://www.ruby-forum.com/t/problems-with-fields-for/81970 "2007-01-16T17:17:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [January 16, 2007, 5:17pm UTC](https://www.ruby-forum.com/t/problems-with-fields-for/81970/1 "2007-01-16T17:17:36Z")

</div>

my models

1. class Empresa \< ActiveRecord::Base

2. has\_many :usuario

3. end

4. class Usuario \< ActiveRecord::Base

5. 
6. 

```
has_one :empresa

```

7. 
8. (…)

partial \_form

\<% form\_for :empresa, @empresa, :url =\> {:action =\> ‘new’} do |emp| %\>

(…)

```
<% fields_for :usuario, @empresa.usuario do |usr|%>
<table>
  <tr>
    <td>Nome:</td>
    <td><%= usr.text_field :nome %></td>
  </tr>

```

(…)

appear the follow error message:  
Esta aparecendo o seguinte erro: undefined method `nomeâ€™ for  
Usuario:Class

What I am making of made a mistake?

| RazÃ£o social: | \<%= emp.text\_field :razao\_social %\> |

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [January 3, 2008, 7:15pm UTC](https://www.ruby-forum.com/t/problems-with-fields-for/81970/2 "2008-01-03T19:15:10Z")

</div>

Hello,  
I am aslo getting the same error regarding undefined local variable or  
method. HAve you figured out what went wrong.  
Could you please tell me the solution if you have resolved it by now.  
Thanks.  
Regards,  
Anks

> partial \_form
> 
> \<% form\_for :empresa, @empresa, :url =\> {:action =\> ‘new’} do |emp| %\>
> 
> appear the follow error message: Esta aparecendo o seguinte erro: undefined method `nomeâ€™ for Usuario:Class
> 
> What I am making of made a mistake?
> 
> |
> | |
