Hi all,
I’m using Rails 2.2.2.
I’m trying to create a hyperlink that will delete an image when it’s
clicked. However I need to
- pass along a bit more info (init_entity_id)
- call this from a different part of the app (the entity page has
images on it, and clicking the delete link next to the image will
delete that image) - specify the class of the link
I can get it working if I don’t specify the class and if I skip the
init_entity_id bit:
<%= link_to ‘[X]’, entity_image, :controller => entity_images’,
:method => :delete, :confirm => ‘Are you sure?’ %>
I can probably work around the CSS issue by putting that in a span or
something. I’d been planning on using the init_entity_id to return to
the entity after the image is deleted. If there were a handy way to
get back there with out passing along that entity’s ID I could get
this working without the below mess…
I’ve tried
<%= link_to ‘[X]’, {:controller => ‘entity_images’, :action =>
‘destroy’, :id => entity_image, :init_entity_id => @entity}, :confirm
=> ‘Are you sure?’, :title => ‘delete this’, :class =>
‘link_to_delete’ %>
which creates
[X]
which shows the image instead of deleting it.
I’ve tried
<%= link_to ‘[X]’, {:controller => ‘entity_images’, :method =>
:delete, :id => entity_image, :init_entity_id => @entity}, :confirm =>
‘Are you sure?’, :title => ‘delete this’, :class => ‘link_to_delete’
%>
which creates
[X]
which lists all the images instead of deleting it.
I’ve tried
<%= link_to ‘[X]’, :controller => ‘entity_images’, :action =>
‘destroy’, :id => entity_image, :init_entity_id => @entity, :confirm
=> ‘Are you sure?’, :title => ‘delete this’, :class =>
‘link_to_delete’ %>
which creates
[X]
which shows the image instead of deleting it.
I’ve tried
<%= link_to ‘[X]’, {:controller => ‘entity_images’, :id =>
entity_image, :init_entity_id => @entity}, :method => :delete,
:confirm => ‘Are you sure?’, :title => ‘delete this’, :class =>
‘link_to_delete’ %>
which creates
[X]
which lists all the images instead of deleting it.
Most other variations on link_to I’ve tried either produce outright
errors in generating the link, or similarly just show the image or
list all images.
I’ve also tried
<%= button_to ‘[X]’, {:controller => ‘trait_value_images’,
:action => “destroy”, :id => trait_value_image, :init_trait_value_id
=> @trait_value}, :method => :delete, :confirm => ‘Are you sure?’,
:title => ‘delete this’ %>
which creates
which does do the delete, but the init_trait_value_id is not sent.
Basically, I think I need a way to specify that the auto-generated
mini-form include something like for either the link
(preferred) or the button.
Any advice on how to get this working?
Thanks
-Chris W