我有一个公司的模型,其 has_one 营业执照模型,如何判断公司的营业执照是否存在?我这样判断: if @company.biz_licence?
结果出错:undefined method `biz_licence?' for #Company:0x007f2614bbcd08。
defined? aa and defined? aa.bb
if @comany.biz_licence 即可
if @comany.biz_licence
if @company.biz_licence.present?可能更好?
if @company.biz_licence.present?
#2 楼 @rociiu 谢谢!这样行了! #3 楼 @ericguo if @company.biz_licence.present? 也试过了,可行!谢谢!
present