rails singular resource still plural?

前端 未结 4 560
天涯浪人
天涯浪人 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 16:00

    Do you want only one route to be generated for the creation?

    If so:

    resource :search, :only => :create
    

    The fact that the controller for the REST resource is named searches_controller is a convention (that you can change, by forcing the controller's name in the route with resource :search, :only => :create, :controller => :search, but it does not worth it...).

提交回复
热议问题