Ruby on rails ActiveRecord与select Rails 4的连接
我有以下AR关系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的
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 ))
}