<%= link_to ((image_tag 'image.png'),
url_for({:controller => 'controller_name', :action => 'action_name'}),
:class => 'quick',
:remote => true) %>
Dieser Teil des Codes generiert mich image.png als Link. Ich müsste diesem Bild etwas Text (Bild + Text) anhängen, ich habe so etwas ausprobiert:
<%= link_to ((image_tag 'image.png', 'text'),
url_for({:controller => 'controller_name', :action => 'action_name'}),
:class => 'quick',
:remote => true) %>
Und ähnliche Wege, aber jeder dieser Versuche endete mit einer Fehlermeldung über schlechte Syntax ... Könnte mir jemand bitte helfen, wie ich es richtig stellen sollte?
Danke im Voraus.
Versuche dies.
<%= link_to image_tag('/images/image.png') + "some extra text", url_for({:controller => 'controller_name', :action => 'action_name'}), :class => 'quick', :remote => true %>
Eine etwas sexyere Lösung?
<%= link_to image_tag("image.png", :alt => "Image Description", :class => "css"), root_path %>
Versuche dies:
<%= link_to (image_tag('image.png') + text,
url_for({:controller => 'controller_name', :action => 'action_name'}),
:class => 'quick',
:remote => true) %>
Das erste Argument ist der Textteil, und mit image_tag erstellen Sie HTML-Code. Sie können jedoch leicht Sachen anhängen.
Ich habe folgendes verwendet und es funktioniert gut:
<%= link_to image_tag("logo.jpg"), controller: 'welcome' %>