Link_to_remote / url path question

I have this helper / link_to_remote link I am trying to switch from
destroy/delete to a separate method/action. Here is the original code.

link_to_remote image_tag(‘delete.png’, :class =>
‘png’, :width=>‘12’, :height=>‘12’), :url => profile_message_path(@p,
message), :method => :delete

Current path that produces looks like this

/profiles/1-username/messages/4

I need it to become

/profiles/1-username/messages/remove/4

I don’t think I am understanding the api docs for this such as
profile_message_path to be able to figure out how to add another
method/action to that URL string. What should my code look like to get
that?

That’s a routing issue; take a look at ActionController::Resources,
specifically the :collection parameter; through it you can introduce
additional resource methods to your routing. E.g.

map.resources :profiles do |profile|
profile.resources :messages, :collection => { :remove => :delete }
end

would give you

/profiles/1-username/messages/4/remove

  • close enough?

Jan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs