2009-10-30 4 views

답변

0

:

map.with_options :controller => 'pages' do |pages| 
    pages.show_page    ':id',    :action => 'show' 
    pages.show_page_with_parent ':id/:parent_id', :action => 'show' 
    end 

당신에 대한 링크 생성하기 위해 지팡이 경우 슬러그 키 이름임을 가정

show_page_with_parent_path(:id => page.name, :parent_id => page.parent.name) 

이 물론 있습니다.

EG :

def custom_show_page_path(page) 
    if page.parent.nil? 
    show_page_path(:id => page.name) 
    else 
    show_page_with_parent_path(:id => page.name, :parent_id => page.parent.name) 
    end 
end 

당신은 물론, 더욱 도우미 기능이 솔루션을 사용자 정의 할 수 있습니다

관련 문제