user1899082
user1899082

Reputation:

Which way of defining routes is more Rails Way-ish and recommended?

Let's say all I need for now is just a GET REST service that returns the JSON when I go to this address:

http://localhost:3000/population_management/1.json

One way is to define it this way:

resources :population_management, :only => [:show]

And one way is to define it this way:

  resources :population_management

  match "population_management/:id" => "population_management#show", :via => :get

And I am sure there are other ways too, So what is your recommendation and why?

Upvotes: 0

Views: 34

Answers (1)

peter
peter

Reputation: 101

the first solution is clearer. plus Rails already defines what you've written in solution two (by using resources -> see here) , so let Rails do it's job, only limit these resources to 1 route.

Upvotes: 1

Related Questions