0
我有這樣一個控制器:過濾器與在內部渲染JSON
def get_tags
person = Person.where({fuid: params[:fuid]})
render json: person, :only=>[:fuid], :include => [
:hashtags => {
:except => [:created_at, :updated_at],
:methods => :person_count
}
]
end
我包括井號標籤,但我需要過濾那些主題標籤只具有active = 1
的人。有沒有辦法做到這一點?在您的控制器
class Person < ActiveRecord::Base
has_many :active_hashtags,-> { where active: 1 }, class_name: 'Hashtags'
end
然後: