Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.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 ActiveRecord与select Rails 4的连接_Ruby On Rails_Activerecord - Fatal编程技术网

Ruby on rails ActiveRecord与select Rails 4的连接

Ruby on rails ActiveRecord与select Rails 4的连接,ruby-on-rails,activerecord,Ruby On Rails,Activerecord,我有以下AR关系 class Restaurant < ActiveRecord::Base has_many :deals end class Deal < ActiveRecord::Base belongs_to :restaurant acts_as_taggable_on :tags end 但问题是,当我调用Restaurant.food_type时,它返回带有交易数据的与Restaurant对象的ActiveRecord关系 你是如何使用select的

我有以下AR关系

class Restaurant < ActiveRecord::Base 
  has_many :deals
end

class Deal < ActiveRecord::Base
  belongs_to :restaurant
  acts_as_taggable_on :tags
end
但问题是,当我调用Restaurant.food_type时,它返回带有交易数据的与Restaurant对象的ActiveRecord关系


你是如何使用select的?选择'restaurants.*'?@mkk,谢谢你的回答,但它不起作用;
scope :food_type, ->(food_types){
  select("*")
  joins(:deals).merge(Deal.tagged_with([food_types], any: true, wild: true )) 
}