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

**URL:** <https://www.ruby-forum.com/t/how-to-extract-the-path-at-the-view-or-how-to-know-who-is-calling-the-polymorph/140000>\
**Category:** Rails\
**Created:** [June 9, 2008, 11:21pm UTC](https://www.ruby-forum.com/t/how-to-extract-the-path-at-the-view-or-how-to-know-who-is-calling-the-polymorph/140000 "2008-06-09T23:21:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andres](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@andres](https://www.ruby-forum.com/u/andres)\
**Post date:** [June 9, 2008, 11:21pm UTC](https://www.ruby-forum.com/t/how-to-extract-the-path-at-the-view-or-how-to-know-who-is-calling-the-polymorph/140000/1 "2008-06-09T23:21:40Z")

</div>

Hi,

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  
end

and  
ï»¿map.resources users do |u|  
u.resources :addresses  
end

(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(@client.id), :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,

Andres
