未定义的方法'+'错误 Rails、Net/http
实际上问题不在于“+”号。但我对此表示怀疑,因为它是该页面中唯一的“+”符号。
导致错误的行是“- res = req.request_head(imageurl.path)” 我的代码:
- req = Net::HTTP.new(imageurl.host, imageurl.port)
- res = req.request_head(imageurl.path)
抛出错误“ActionView::Template::Error (undefined method `+' for nil:NilClass):” 有什么问题吗?
非常感谢您的所有帮助&对于造成的不便,我们深表歉意。
但问题仍然没有解决。
Actually the problem was not with the '+' sign. But i doubted it because, it was the only '+' sign in that page.
The line which causes the error is "- res = req.request_head(imageurl.path)"
My code:
- req = Net::HTTP.new(imageurl.host, imageurl.port)
- res = req.request_head(imageurl.path)
throws the error "ActionView::Template::Error (undefined method `+' for nil:NilClass):"
what is the issue?
Thanks a lot for all the helps & sorry for the inconveniences caused.
But the issue is still not fixed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以使用标准的 ruby 方法以更优雅的方式实现你想要的,例如:
如果你需要在每 25 个产品之后使用
li
,你可以使用each_slice
:虽然它是不是你问题的答案(其他答案应该适合你),但这种方法更红利。
You can use standard ruby methods to achieve what you want in more elegant way, for example:
If you need that
li
after each 25th product, you can useeach_slice
:Though it's not an answer to your question (other answers should work for you), but this approach is more rubiest.
看起来名为
scount
的对象上的方法to_i
返回 nil。对我来说下一步似乎是调查scount
的类。在下面的评论后更新一些代码;
It seems that the method
to_i
on the object calledscount
is returning nil. An investigation into what the class ofscount
may be seems like the next step to me.Update with some code after comments below;
下面应该可以工作 -
Below should work -