This operator should return -1, 0, or 1. According to my very brief
test in irb, an empty serial might be fine while a nil serial will
throw an error.
irb(main):001:0> a = ["serial", "1"]
=> ["serial", "1"]
irb(main):002:0> b = ["", "2"]
=> ["", "2"]
irb(main):003:0> a <=> b
=> 1
irb(main):004:0> b = [nil, "2"]
=> [nil, "2"]
irb(main):005:0> a <=> b
=> nil
My guess is that when #sort gets nil instead of -1, 0, or 1, it throws
the error. Of course, I haven't looked deeply into the source, so I
could be wrong. Again, irb suggests this:
irb(main):006:0> arr = [a, b]
=> [["serial", "1"], [nil, "2"]]
irb(main):007:0> arr.sort
ArgumentError: comparison of Array with Array failed
from (irb):7:in `sort'
from (irb):7
Perhaps you could replace "elt.serial" with "(elt.serial || '')". If
that doesn't work - or if my ideas are horrible - somebody else will
help you, I'm sure.
-Kyle
···
from :0
On May 20, 7:25 am, c-note <c-n...@hotmail.fr> wrote:
Hi all,
i got this error when the field serial is empty.
Showing app/views/find/index.rhtml where line #44 raised: