Problems with fields_for

my models

  1. class Empresa < ActiveRecord::Base

  2. has_many :usuario

  3. end

  4. class Usuario < ActiveRecord::Base

  5. has_one :empresa
    
  6. (…)

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 %>

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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs