link_to(image_tag) in rails


To make a image as a link, you have to use the following syntax,

<%= link_to(image_tag(“delete.png” , :size => “50×22″ ),
{ :controller => “admin” ,
:action=> “delete” ,
:id => @product},
{ :confirm=> “Are you sure?” })
%>

2 responses to this post.

  1. Posted by Ray Parker on September 8, 2010 at 5:04 pm

    With the above code I get a GET on the item and I’m taken to the show view, and no confirmation still. Any updates on delete confirmation with a link_to/image_tag? I’ve been wresting with this one on and off for a few weeks (Rails3 rc.* and Rails 3.0.0)

    Reply

  2. Posted by Ben on March 19, 2011 at 2:35 am

    @ray
    image_submit_tag ?

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.