<分区>
我有一个网址:
xxxx/xxx?status=2
我从 URL 中获取了 :status
参数的值,将其转换为整数,并尝试在其上使用 between
方法:
params[:status].to_i.between.(0, 3)
但是我得到如下错误:
undefined method `between' for 1:Fixnum
我检查了类(class)祖先:
params[:status].to_i.class.ancestors
# => [Fixnum, JSON::Ext::Generator::GeneratorMethods::Fixnum, Integer, Numeric, Comparable, Object, ActiveSupport::Dependencies::Loadable, JSON::Ext::Generator::GeneratorMethods::Object, Kernel, BasicObject]
我可以看到 Comparable
,所以我不明白为什么我做不到。