Use of button_to to access action "new"

I have a question about what is regarded as good practice in the context of RESTful Rails interfaces.

I have a Subscribers Controller with "index" and "new" (and other) actions. In routes.rb I define resource-based routing with "map.resources :subscribers".

In my index view I have a button_to that points to "new_subscriber_path". Since the button generates a POST request, which doesn't match any resource-based routes, I also have "map.connect ':controller/:action'" in routes.rb to ensure that the request goes to the intended "new"action.

This does exactly what I want it to, but it seems a little awkward to have defined RESTful routes, and in this particular case to not use one because of a UI design choice I've made (a button instead of a link). Should this be viewed as a limitation in the way Rails supports REST, or is there a different way I should be doing this?

Mark.

MarkMT wrote:

In my index view I have a button_to that points to "new_subscriber_path". Since the button generates a POST request, which doesn't match any resource-based routes, I also have "map.connect ':controller/:action'" in routes.rb to ensure that the request goes to the intended "new"action.

button_to creates a form, and forms can GET. That is in fact what forms do by default, but rails specifies that they should be POST because that's what most people probably want. Anyway, button_to "Foo", bar_path, :method => :get is the way to go, rather than adding routes like that.

Thank you! Just what I needed to know!

Mark.