link_to image tag. how to add class to a tag

前端 未结 11 1859
失恋的感觉
失恋的感觉 2020-12-22 20:53

I am using link_to img tag like following

<%= link_to image_tag(\"Search.png\", :border=>0, :class => \'dock-item\'), 
:action => \'search\', :co         


        
11条回答
  •  萌比男神i
    2020-12-22 21:07

    To respond to your updated question, according to http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html...

    Be careful when using the older argument style, as an extra literal hash is needed:

      link_to "Articles", { :controller => "articles" }, :id => "news", :class => "article"
      # => Articles
    

    Leaving the hash off gives the wrong link:

      link_to "WRONG!", :controller => "articles", :id => "news", :class => "article"
      # => WRONG!
    

提交回复
热议问题