Route alias in Rails

后端 未结 3 1201
夕颜
夕颜 2020-12-08 13:15

I have a model stories in Rails 3.

I want to make an alias \"books\" for \"stories\" so I can have routes /books/192 instead of /stories/192

3条回答
  •  清歌不尽
    2020-12-08 13:53

    Try something like this:

    match 'books/:id' => 'books#show'
    match 'books' => 'books#index'
    

提交回复
热议问题