Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 从活动记录关系获取模型类_Ruby On Rails_Ruby_Activerecord - Fatal编程技术网

Ruby on rails 从活动记录关系获取模型类

Ruby on rails 从活动记录关系获取模型类,ruby-on-rails,ruby,activerecord,Ruby On Rails,Ruby,Activerecord,我有一个Rails模型: class Foo < ActiveRecord::Base ... end 如何获得原始模型类 limited_foo ... # => Foo ActiveRecord::Relation有一个属性\u readerklass: limited_foo.klass #=> Foo 消息来源是。别名模型也可以使用 limited_foo.klass #=> Foo

我有一个Rails模型:

class Foo < ActiveRecord::Base
  ...
end
如何获得原始模型类

limited_foo ... # => Foo

ActiveRecord::Relation
有一个属性\u reader
klass

limited_foo.klass
#=> Foo
消息来源是。别名
模型
也可以使用

limited_foo.klass
#=> Foo