rails singular resource still plural?

前端 未结 4 566
天涯浪人
天涯浪人 2021-01-31 15:22

I have a search route which I would like to make singular but when I specify a singular route it still makes plural controller routes, is this how it\'s supposed to be?

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 15:58

    Is the search really a resource? If it is, then what you a creating is an instance of a model with a type of "search", in which case the plural controller "searches" makes perfect sense.

    However, if it's a controller that doesn't have multiple models, then maybe not. In which case, you don't need to define the routes with resource :search you can simply use get 'search/create' to tell the router to answer "search/create" to the 'create' action in your 'search' controller.

提交回复
热议问题