rails multiple link_to_if link_to link example ruby-on-rails-3 image link-to

ruby-on-rails-3 - multiple - rails link_to controller action



Rieles 3-link_to con image_tag+texto (4)

<%= link_to ((image_tag ''image.png''), url_for({:controller => ''controller_name'', :action => ''action_name''}), :class => ''quick'', :remote => true) %>

Esta parte del código me generará image.png como un enlace. Necesitaría agregar a esta imagen un texto (imagen + texto), intenté algo como:

<%= link_to ((image_tag ''image.png'', ''text''), url_for({:controller => ''controller_name'', :action => ''action_name''}), :class => ''quick'', :remote => true) %>

Y formas similares, pero cada uno de estos intentos terminó con un mensaje de error sobre la sintaxis incorrecta ... ¿Podría alguien ayudarme, por favor, cómo debería corregirlo?

Gracias por adelantado.


¿Una solución ligeramente más sexy?

<%= link_to image_tag("image.png", :alt => "Image Description", :class => "css"), root_path %>


Prueba esto.

<%= link_to image_tag(''/images/image.png'') + "some extra text", url_for({:controller => ''controller_name'', :action => ''action_name''}), :class => ''quick'', :remote => true %>


Prueba esto:

<%= link_to (image_tag(''image.png'') + text, url_for({:controller => ''controller_name'', :action => ''action_name''}), :class => ''quick'', :remote => true) %>

El primer argumento es la parte de texto y con image_tag crea HTML, pero puede agregar cosas fácilmente.


Utilicé lo siguiente y funciona bien:

<%= link_to image_tag("logo.jpg"), controller: ''welcome'' %>