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"%> <%=submit_tag 'SEARCH INDIVIDUAL', :name=>"submit"%> <%=render :partial=>'person_fields' , :locals=>{:p=>p}%>
<%=submit_tag 'CREATE INDIVIDUAL', :name=>"submit"%> <%=submit_tag 'SEARCH INDIVIDUAL', :name=>"submit"%>
<%fields_for "person[organisation_attributes]",organisation do
org_form|%>
<div id = "organisation"><%=render :partial=>'organisation_with_index_nil_for_person',:collection=>@person.organisations,:locals=>{:org_form=>org_form}%> </div> <b><%=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%></b> <%end%> <%end%>
Please help me Thanks Regards Anks.