# Rendering partial forms

**URL:** <https://www.ruby-forum.com/t/rendering-partial-forms/147225>\
**Category:** Rails\
**Created:** [August 29, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/rendering-partial-forms/147225 "2008-08-29T16:20:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [August 29, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/rendering-partial-forms/147225/1 "2008-08-29T16:20:44Z")

</div>

Hi, I’m trying to use partials to render some forms to create new  
records and to edit existing ones.

But I’m getting the following error

Called id for nil, which would mistakenly be 4 – if you really wanted  
the id of nil, use object\_id

Obviously for the edit form I need to somehow pass the id to the form,  
but why is the same error occurring when I try to create a new record?

Any advice in solving either problem would be appreciated. Thanks:)

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [August 29, 2008, 4:38pm UTC](https://www.ruby-forum.com/t/rendering-partial-forms/147225/2 "2008-08-29T16:38:01Z")

</div>

> Called id for nil, which would mistakenly be 4 – if you really wanted  
> the id of nil, use object\_id

That has nothing to do with partials. (Maybe with the specific way you  
use them)  
It just tells you, that and object that should have a value is nil.  
Maybe you forgot  
to hand in that with the :object argument in the render :partial call.

Please post your code and tell us in which line the error happened

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [August 29, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/rendering-partial-forms/147225/3 "2008-08-29T17:13:57Z")

</div>

Hi, nevermind I think I might have actually worked something out by  
myself for once lol

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [August 29, 2008, 8:03pm UTC](https://www.ruby-forum.com/t/rendering-partial-forms/147225/4 "2008-08-29T20:03:59Z")

</div>

> Called id for nil, which would mistakenly be 4 – if you really wanted  
> the id of nil, use object\_id

I’ve had this show up many times. It helps that on your partial you  
check the incoming objects before using them.  
Something like  
\<% obj = ‘default value’ if obj == nil %\>
