How to extract the path at the view, or how to know who is calling the polymorph?


I have addresses as a polymorphic,

it includes adressable_type and addressable_id

in my routes I have

map.resources client do |c|

c.resources :addresses



map.resources users do |u|

u.resources :addresses


(and many more that have addresses)

I have an ajax form to add addresses

but the way I have it is not very nicely styled,

at the end of the form, I submit it with

    <%=	button_to_remote("Add Address",

		:submit => "address_form",

		:url     =>  client_address_path(, :method => 'post'



but Instead of the url line to be hard-coded, I

I’d like the url line to be inflected from the context on which the form was called,

(client or user)

I am reading through the api, but I can’t find how to extract the path and convert it on its components,

any hint on whether there’s a rails method built for it,

or which approach to take is appreciated,

Thank you,