2012-04-16 3 views
0

나는 예에 의해, 그래서 A는 has_many :through 협회 그래서 집 등has_many : URL /보기의 연결을 통해?

나는 사용자 지정 쿼리를했다 "풀 하우스" "lastminute"등의 다중 카테고리를 가질 수 있습니다, 내 주택 모델 (테이블 조인) 추가 I 콘솔에서 "lastminute"카테고리 (5)

@lastminutes = House.find(:all, :select=>"houses.*", :joins=>"JOIN category_join_tables ON houses.id = category_join_tables.house_id", :conditions=>["category_join_tables.house_id = houses.id AND category_join_tables.category_id = ?", 5]) 

이 잘 작동의 모든 집을 원한다.

내 사이트에서이 기능을 작동시키는 가장 좋은 방법은 무엇입니까? 나는 URL stucture가 다음을 원한다 :

domain.com/locale/holidayhouses/lastminutes (house in the lastminute category) 
domain.com/locale/holidayhouses/holidayhouses_with_pool (houses in the pool category) 

domain.com/locale/lastminutes (houses and appartments in the lastminute category) 

도움이 될 것입니다!

답변

1

그것은 매우 쉽습니다 :

설정/routes.rb : 이제 배열로 범주를 얻을 만 쿼리로 구문 분석 할 필요가 액션에

match 'search/*categories' => "controller#action" 

. 그렇지 않으면 레일스가 모든 정상적인 요청을 카테고리로 취하고 조치로 리디렉션하기 때문에 "검색"이 필요하다고 생각합니다.

scope "/:locale" do 
    # move all the other routes in here to work with the locale 
end 

체크 아웃 국제화

rails guide처럼 할 수있는 l18n 부분의 경우 How to embed multiple tags in Rails routes, like Stack Overflow


참조

관련 문제