Haml: link_to vs button_to

button, haml, hyperlink, ruby-on-rails

Solution

It's simpler that you think. That methods are Rails helpers and don't have anything to do with haml. Yes, one method is for get and another for post methods. If you need to post any data to controller, use `button_to` (for example when deleting a record). Otherwise, `link_to` is enough.

Moreover, you can make `link_to` posting data using `:method` parameter:

= link_to "Something", some_path, :method => :post

Answering your question, use `link_to`.

Problem

From what I understand, `link_to` is used for get methods, and `button_to` is used for post methods. On the other hand, I was told that with HTML5 semantics, `<button>` is used for any type of clickable...well, button. In the case I have a clickable button that sends a user to a form to fill out, should I create a `button_to` or a `link_to`?

Original source