카테고리 없음

[ruby-on-rails-3] Rails 3-link_to with image_tag + text

행복을전해요 2020. 12. 12. 19:25

이 시도.

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

약간 섹시한 솔루션?

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

이 시도:

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

첫 번째 인수는 텍스트 부분이고 image_tag를 사용하여 HTML을 만들지 만 쉽게 추가 할 수 있습니다.

-------------------

나는 다음을 사용했고 잘 작동합니다.

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


출처
https://stackoverflow.com/questions/7415058