# Has\_many show partial new foreign key - help

**URL:** <https://www.ruby-forum.com/t/has-many-show-partial-new-foreign-key-help/146498>\
**Category:** Rails\
**Created:** [August 21, 2008, 6:03pm UTC](https://www.ruby-forum.com/t/has-many-show-partial-new-foreign-key-help/146498 "2008-08-21T18:03:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [August 21, 2008, 6:03pm UTC](https://www.ruby-forum.com/t/has-many-show-partial-new-foreign-key-help/146498/1 "2008-08-21T18:03:44Z")

</div>

Hi  
i have a 1-N Model: Company\<\>Division. everything is default. I want to  
have a Division/new partial in the Company/show view. so what i did was  
copying the new to \_new and render it with:  
Company/show:

**Title:** \<%=h @account.title %\>

.....

\<%= render :partial=\>‘contacts/new’, :local=\>@contact=Contact.new %\>

…

but now i dont know hoe to get the @acount\_id into the Division-Model as  
foreign key!?  
what do i need to do here?

thx

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [August 21, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/has-many-show-partial-new-foreign-key-help/146498/2 "2008-08-21T20:40:37Z")

</div>

could you:

\<%= render\_partial ‘contacts/new’, nil, ‘contact’ =\> Contact.new,  
‘account’ =\> @account.id %\>

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [August 21, 2008, 9:07pm UTC](https://www.ruby-forum.com/t/has-many-show-partial-new-foreign-key-help/146498/3 "2008-08-21T21:07:56Z")

</div>

i tried:

\<%= render :partial=\>‘contacts/new’, nil, :contact=\> Contact.new,  
:account=\> @account.id %\>

but this didnt work:  
compile error  
/var/www/railapps/TEST5/app/views/accounts/show.html.erb:8: syntax  
error, unexpected ‘,’, expecting tASSOC  
\_erbout.concat(( render :partial=\>‘contacts/new’, nil, :contact=\>  
Contact.new, :account=\> @account.id ).to\_s); \_erbout.concat “\n”  
^  
/var/www/railapps/TEST5/app/views/accounts/show.html.erb:8: syntax  
error, unexpected tASSOC, expecting tCOLON2 or ‘[’ or ‘.’  
\_erbout.concat(( render :partial=\>‘contacts/new’, nil, :contact=\>  
Contact.new, :account=\> @account.id ).to\_s); \_erbout.concat “\n”

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [August 22, 2008, 4:55am UTC](https://www.ruby-forum.com/t/has-many-show-partial-new-foreign-key-help/146498/4 "2008-08-22T04:55:47Z")

</div>

Any difference if you take that nil arg out of there?

If not, maybe this would work:

\<%= render :partial=\>‘contacts/new’, :contact =\> Contact.new(:account\_id  
=\> @account.id) %\>

?

-Roy
