m getting an error “Called id for nil, which would mistakenly be 4 – if
you really wanted the id of nil, use object_id”
when i’m creating new record,like a topic has many discussions,when i’m
creating a new discussions m getting that error…i already assign the
topic id as foreign key in discussions controller…please sort out
this problem.if u getting the same…how you rectify those errors…and in
how many cases this errors are prone to occur???
m getting an error “Called id for nil, which would mistakenly be 4 – if you
really wanted the id of nil, use object_id”
when i’m creating new record,like a topic has many discussions,when i’m creating
a new discussions m getting that error…i already assign the topic id as foreign
key in discussions controller…please sort out this problem.if u getting the
same…how you rectify those errors…and in how many cases this errors are prone to
occur???
We need more information to help you , can you post part of the relevant
code?
private
def find_subject
if params[:subject_id] @subject = Subject.find_by_id(params[:subject_id])
end
end
end
You’re calling find_subject on a before_filter, and it may or may not
populate a @subject object depending on whether there’s a param value.
But your action then goes on to expect there to definitely be an @subject instance variable. Put a breakpoint in find_subject, and see
what the parameter values are.
m getting an error “Called id for nil, which would mistakenly be 4 – if you
really wanted the id of nil, use object_id”
when i’m creating new record,like a topic has many discussions,when i’m
creating a new discussions m getting that error…i already assign the topic
id as foreign key in discussions controller…please sort out this
problem.if u getting the same…how you rectify those errors…and in how many
cases this errors are prone to occur???
This means that you have some code some_object.id where some_object is
nil. The error message should tell you which line is failing. Have a
look at the Rails Guide on debugging for ideas on how to debug your
code to find the problem.