这是代码:
if article.link && article.link.starts_with?(`https://www.youtube.com`) then article.link end
错误是指这部分:
article.link.starts_with?(`https://www.youtube.com`)
但是,如果 article.link 为零,则甚至不应该评估该部分。
如果问题出在article.link
错误上
NoMethodError: undefined method `starts_with?' for nil:NilClass
事实上,问题出在https://www.youtube.com
表达式上。它的计算结果为nil
。 你为什么要使用这些引号?将它们更改为""
或''