Hello ruby People!
I’m learning ruby right now,and i got a easy question for you guys!
whenever i have a model with nil objects,when i try to actually see the
record I get the error
“You have a nil object when you didn’t expect it!”
I knwo what this error means and i know why it’s happenning in my
case,but my question is:
what should i do to make rails show nil objects as blank
fields?like I’m try ing to add a new user to my system and there’s 4
fields: id,username,password,description…
let’s say i did fill 2 of them(id is auto increment),and left the last
one blank…now i wanna show my record into my view,but I’m sure i will
get this error…
You have a nil object when you didn’t expect it!
i know how to work around this also...i did something like this :
unless @model.name.nil?
@model.name
end
but if have to do this for EVERY field into my view,i pretty much feel
like rails isn’t being as much productivity as it’s supposed to be…
i’m sorry for my english and of course if i’m saying something stupid
please correct me guys! thankz man!