Is there an easy way to change the default method that a particular HTTP Verb maps to when dealing with RESTful rou开发者_StackOverflow社区ting in rails? Let's say each of my model controllers has a delete action instead of destroy, however when I use:
link_to "Delete", some_object, :method => :delete
Rails does what it's supposed to and routes to the destroy action of my resource's controller. Instead, I'd like to route to an action named delete. That's it.
I know I can just use ruby's alias in my controllers or add a custom member route for each of my resources, but is there an easier way to do this to make the changes app-wide? Thanks!
If you use alias in your ApplicationController, then that will flow through to your other controllers that inherit from it.
That will function the way you want it to.
Warning: rails is opinionated software and generally you won't want to step too far out of the way rails works. And rails loves standard REST actions.
精彩评论