# Please help getting error in fields\_for

**URL:** <https://www.ruby-forum.com/t/please-help-getting-error-in-fields-for/124905>\
**Category:** Rails\
**Created:** [January 3, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/please-help-getting-error-in-fields-for/124905 "2008-01-03T17:43:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 3, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/please-help-getting-error-in-fields-for/124905/1 "2008-01-03T17:43:13Z")

</div>

Hi,  
I am using the fields\_for and am getting a problem of

“undefined local variable or method `organisation’ for  
#\<#Class:0x4775534:0x477550c\>”

my person model is as

class Person \< ActiveRecord::Base  
has\_and\_belongs\_to\_many :organisations

My Organisation model is as  
class Organisation \< ActiveRecord::Base  
has\_and\_belongs\_to\_many :people

Please help me with this. I was following the railscasts complex forms2  
74

This is the code for form to create a new person and simultaneously  
create an organisation for that person.

\<%form\_for :person,:url=\>{:action =\>“submit\_tag”} do |p|%\>  
\<%=submit\_tag ‘CREATE INDIVIDUAL’, :name=\>“submit”%\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
\<%=submit\_tag ‘SEARCH INDIVIDUAL’, :name=\>“submit”%\>  
\<%=render :partial=\>‘person\_fields’ , :locals=\>{:p=\>p}%\>

\<%=submit\_tag ‘CREATE INDIVIDUAL’, :name=\>“submit”%\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
\<%=submit\_tag ‘SEARCH INDIVIDUAL’, :name=\>“submit”%\>

\<%fields\_for “person[organisation\_attributes][]”,organisation do  
|org\_form|%\>

\<%=render :partial=\>'organisation\_with\_index\_nil\_for\_person',:collection=\>@person.organisations,:locals=\>{:org\_form=\>org\_form}%\>
**\<%=link\_to\_function "Add an Organisation" do |page| page.insert\_html :bottom,:organisation,:partial=\>'organisation/organisation\_with\_index\_nil\_for\_person',:object=\>Organisation.new end%\>** \<%end%\> \<%end%\>

Please help me  
Thanks  
Regards  
Anks.
