Rails Routing (root :to => …)

后端 未结 6 1626
北恋
北恋 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:44

    I'm using Rails 5.1 to point the home page to a specific blog. In config/routes.rb I have ...

    root 'blogs#show', {id: 1}
    

    This will point the root route to /blogs/1

    I'm doing this on a blog site I'm building. The first blog will be the main site blog as well as the homepage.

    Cheers

提交回复
热议问题