Rendering partial forms

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:)

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

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

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