Akash Pinnaka
Akash Pinnaka

Reputation: 475

Which routes should I use in rails match :controller(/:action(/:id)) or resources?

I am using match :controller(/:action(/:id)) as routing system.

I didn't see anyone using this type of routing system. All are using resources routes.

Is this the best way to make routing or what is the best preference for routing?

Upvotes: 2

Views: 78

Answers (4)

ramesh
ramesh

Reputation: 51

You can use any routes you want unless you are creating an API. If you are creating an API, you need RESTful routes. resources provides you with restful routes.

Upvotes: 1

spickermann
spickermann

Reputation: 106892

I think @AndreyDeineko provided a good answer.

Another problem with match :controller(/:action(/:id)) I noticed a while ago, is that it might lead to security issues:

Imagine you have methods your application_controller.rb that are not marked as private. Since all other controllers inherit from ApplicationController everyone can call these methods just by guessing names.

Upvotes: 1

Roman Kiselenko
Roman Kiselenko

Reputation: 44370

Deprecate method "match" in routes.rb

... proposal is to announce 'match' method in routes.rb as deprecated and later(e.g. rails 5.0) put it to "private methods" section.

It will encourage people to use "pure" restful methods-verbs like put post get etc and will raise knowledge of their meaning and goal. (GET for retrieving data, POST for state changing requests)

Why? - my points are described at http://homakov.blogspot.ru/2012/04/whitelist-your-routes-match-is-evil.html

Upvotes: 1

Andrey Deineko
Andrey Deineko

Reputation: 52357

It is RESTful routing you are missing :)

Upvotes: 2

Related Questions