2012-06-25 5 views
0

나는어떻게 하나 이상의 q = 쿼리에 대한 결과를 얻을 수 있습니까?

http://localhost:3000/tags?utf8=✓&q=2%2C12%2C44

그것은 최초의 태그 ID를 위해 작동하지만 (사람들은 태그의 id이다)이 형태의 URL을 제출 내 사이트에 검색 폼이없는 다른

def self.search(query = {}) 
    output = self.scoped 
    output = output.where(:id => query[:q]) 
    end 

TagsController : 쿼리를 할 때

def index 
    @tags = Tag.search(params) 
    end 

답변

0

ActiveRecord::Base.where는 인수로 배열을 받아 여러 경기가 있습니다. 검색어 매개 변수를 배열로 바꾸려면 split :

output = output.where(:id => query[:q].split(',')) 
관련 문제