Recursive routes in Rails

后端 未结 1 989
孤独总比滥情好
孤独总比滥情好 2021-02-04 11:14

Is is possible to create a recursive route in Rails?

I have an application, which allows a admin to create pages. The page model is a nested set and so each page has a p

相关标签:
1条回答
  • 2021-02-04 11:51

    You can map the initial route (/page) to the controller, setting up "globbing" for all the trailing parameters.

    map.connect '/:page/*pages', :controller => 'pages', :action => 'show' 
    

    params[:pages] will now contain an array of the page parameters (matching as many trailing params as you specify in the URL).

    0 讨论(0)
提交回复
热议问题