Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/10/2006, 09:02
tomasulo
 
Fecha de Ingreso: agosto-2006
Mensajes: 316
Antigüedad: 17 años, 9 meses
Puntos: 0
button_to vs link_to

me he documentoado y veo q existen dos helpers button_to y link_to
la diferencia entre los dos esta clara, y tb creo q tengo se para que se tiene que utilizar cada cosa, pero mi ingles no es muy completo y no termino de entender lpq en algunos casos es mejor utilizar button_to .

Código:
The problem is that the link_to( ) helper
generates an HTML
<
a href=...
>
tag. When you click on the corresponding link, your browser generates an HTTP GET request to the server. And HTTP GET requests are not supposed to change the state of anything on the server they're only to be used to fetch information.
We previously showed the use of :post => true
as one solution to this problem.
Rails provides a useful alternative: the button_to
( ) method also links a view back to the application, but it does so by generating an HTML form that contains just a single button. When the user clicks the button, an HTTP POST request is generated. And a POST request is just the ticket when we want to do something like add an item to a cart.