link_to image tag. how to add class to a tag

前端 未结 11 1856
失恋的感觉
失恋的感觉 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条回答
  •  伪装坚强ぢ
    2020-12-22 21:04

    The whole :action =>, :controller => bit that I've seen around a lot didn't work for me.

    Spent hours digging and this method definitely worked for me in a loop.

    <%=link_to( image_tag(participant.user.profile_pic.url(:small)), user_path(participant.user), :class=>"work") %>
    

    Ruby on Rails using link_to with image_tag

    Also, I'm using Rails 4.

提交回复
热议问题