# URL mapping in routes.rb

**URL:** <https://www.ruby-forum.com/t/url-mapping-in-routes-rb/132329>\
**Category:** Rails\
**Created:** [March 19, 2008, 6:26am UTC](https://www.ruby-forum.com/t/url-mapping-in-routes-rb/132329 "2008-03-19T06:26:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthikeyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/898d66/32.png) [@karthikeyan](https://www.ruby-forum.com/u/karthikeyan)\
**Post date:** [March 19, 2008, 6:26am UTC](https://www.ruby-forum.com/t/url-mapping-in-routes-rb/132329/1 "2008-03-19T06:26:25Z")

</div>

Hi,

I have the following mapping in routes.rb.

map.resources :definitions, :member=\>{:execute=\>:post},  
:collection=\>{:select=\>:get} do |def|  
def.resources :definition\_fields  
end

Now I am able to access the ‘index’ method of  
definition\_fields\_controller.rb by the following code.

definition\_definition\_fields\_path(@definition)

It works well. But when I tried calling the ‘new’ method of  
definition\_fields\_controller.rb with the following syntax, it failed.

definition\_new\_definition\_field\_path(@definition)

What is the right way to call the ‘new’ and ‘edit’ methods when this  
kind of mapping is used???

Thanks in advance…

- Karthik.

---

<div class="post-metadata">

**Author:** ![karthikeyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/898d66/32.png) [@karthikeyan](https://www.ruby-forum.com/u/karthikeyan)\
**Post date:** [March 19, 2008, 9:19am UTC](https://www.ruby-forum.com/t/url-mapping-in-routes-rb/132329/2 "2008-03-19T09:19:47Z")

</div>

Karthi kn wrote:

> map.resources :definitions, :member=\>{:execute=\>:post},  
> :collection=\>{:select=\>:get} do |def|  
> def.resources :definition\_fields  
> end

You will probably want to replace “def” with something else as it is a  
Ruby keyword…

> What is the right way to call the ‘new’ and ‘edit’ methods when this  
> kind of mapping is used???

new\_definition\_definition\_field  
edit\_definition\_definition\_field

Your friend here is “rake routes” which will give you all the details of  
how URLs are mapped to controllers and actions and what helper methods  
are available.
