Why do I need to work harder to make my Rails application fit into a RESTful architecture?

后端 未结 6 629
有刺的猬
有刺的猬 2020-12-23 11:44

I started a Rails project recently and decided to use RESTful controllers. I created controllers for my key entities (such as Country) and added index, ne

6条回答
  •  执念已碎
    2020-12-23 12:20

    If I go beyond the standard CRUD actions with my models, I normally just add the methods as required. Searching is something I add to many controllers, but not every one, so I add it and maintain the routes normally:

    map.resources :events, :collection => { :search => :get }
    

    Moving these actions to an entirely separate controller might keep some of your controllers RESTful, but I find that keeping them in context is far more useful.

提交回复
热议问题