Rails Routing (root :to => …)

后端 未结 6 1580
北恋
北恋 2021-01-31 02:03

I know how to set the routes root of my rails app to a controller and an action.

But how to add an id?

/pages/show/1 should be the root.

How

6条回答
  •  被撕碎了的回忆
    2021-01-31 02:37

    Try:

     match 'pages/show/:id' => 'pages#show', :as => :root
    

    In Rails console. rake routes | grep root, should show something like:

    root     /pages/show/:id(.:format)      {:controller=>"pages", :action=>"show"}
    

    Hope that helps.

提交回复
热议问题