Rails 3 - link_to with image_tag + text

后端 未结 4 1907
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 01:56
<%= link_to ((image_tag \'image.png\'), 
        url_for({:controller => \'controller_name\', :action => \'action_name\'}), 
            :class => \'quick\',         


        
相关标签:
4条回答
  • 2021-02-04 02:25

    A slightly sexier solution?

    <%= link_to image_tag("image.png", :alt => "Image Description", :class => "css"), root_path %>
    
    0 讨论(0)
  • 2021-02-04 02:29

    Try this:

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

    The first argument is the text part and with image_tag you create HTML, but you can easily append stuff.

    0 讨论(0)
  • 2021-02-04 02:31

    I used the following and it works just fine:

    <%= link_to image_tag("logo.jpg"), controller: 'welcome' %>
    
    0 讨论(0)
  • 2021-02-04 02:32

    Try this.

    <%= link_to image_tag('/images/image.png') + "some extra text", url_for({:controller => 'controller_name', :action => 'action_name'}), :class => 'quick', :remote => true %>
    
    0 讨论(0)
提交回复
热议问题