我有一个网址:
xxxx/xxx?status=2我从URL中获取了:status参数的值,将其转换为整数,并尝试在其上使用between方法:
params[:status].to_i.between.(0, 3)但我得到的错误如下:
undefined method `between' for 1:Fixnum我检查了班里的祖先:
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,所以我不明白为什么我不能这么做。
发布于 2014-09-28 16:21:19
方法名有错误:不是between,而是between?
params[:status].to_i.between?(0, 3)检查鲁比博士。
https://stackoverflow.com/questions/26086928
复制相似问题