Rails button to-aplicar la clase css al botón


Esto es una tontería, pero simplemente no puedo averiguar cómo estilizar el elemento de entrada creado por Rails button_to {y sí, he leído los documentos una y otra vez y he probado las muestras.

Aquí está mi código ERB:

 <%= button_to "Claim", action: "claim", idea_id: idea.id, remote: true, class: 'btn btn-small'  %>

Y esto produce el siguiente HTML:

<form action="/ideas/claim?class=btn+btn-small&amp;idea_id=4&amp;remote=true" class="button_to" method="post">
  <div>
    <input data-remote="true" type="submit" value="Claim">
    <input name="authenticity_token" type="hidden" value="pU3umgqrDx3WbalfNK10c9H5B5N4OzPpohs4bWW8mow=">
  </div>
</form>

Mientras que todo lo que quiero es input tener class = "btn btn-small".

¿Ayuda? ¡Gracias!

Author: ezuk, 2013-01-02

2 answers

La firma del método button_to es

button_to(name = nil, options = nil, html_options = nil, &block)

Así que use {} para distinguir options y html_options

<%= button_to "Claim", {action: "claim", idea_id: idea.id, remote: true}, {class: 'btn btn-small'} %>
 38
Author: Baldrick,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-29 14:21:25

<%= button_to "Claim", {action: "claim", idea_id: idea.id, remote: true}, {form_class: 'form', class: 'btn btn-small'} %>

Form_class: clase para la forma

Class: clase para el botón en la forma

 8
Author: My Mai,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-11 02:17:27