# With\_options

**URL:** <https://www.ruby-forum.com/t/with-options/156906>\
**Category:** Rails\
**Created:** [January 5, 2009, 5:53am UTC](https://www.ruby-forum.com/t/with-options/156906 "2009-01-05T05:53:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [January 5, 2009, 5:53am UTC](https://www.ruby-forum.com/t/with-options/156906/1 "2009-01-05T05:53:23Z")

</div>

Hi  
why is this used in routes.rb I have code like below But I did not  
understand what it means Could anybody please clarify this?

map.with\_options(:controller =\> “companies”) do |companies\_map|

companies\_map.companies\_view\_custom\_field\_permissions  
‘/companies/view\_custom\_field\_permissions’,  
:action =\> ‘view\_custom\_field\_permissions’

companies\_map.with\_options(:my\_company =\> true) do |my\_company\_map|  
my\_company\_map.my\_company  
‘/my\_company/:company\_id’, :action =\> ‘show’,  
:company\_id =\> ‘root’

end

end

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [January 5, 2009, 10:24am UTC](https://www.ruby-forum.com/t/with-options/156906/2 "2009-01-05T10:24:43Z")

</div>

On Jan 5, 4:53 am, Sijo Kg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi  
> why is this used in routes.rb I have code like below But I did not  
> understand what it means Could anybody please clarify this?

> **[with\_options for fun and profit - Space Vatican](https://www.spacevatican.org/2008/11/25/with_options-for-fun-and-profit/)**
>
> Active Support has a nifty little helper that can cut down on repetition. A lot of things in Rails like validations, associations, named\_scopes, …

Fred

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [January 5, 2009, 11:09am UTC](https://www.ruby-forum.com/t/with-options/156906/3 "2009-01-05T11:09:45Z")

</div>

Hi  
Thanks for the link…Also have doubts on why to specify collection,  
path\_prefix etc For example

map.resources :projects, :collection =\> { :all =\> :get, :my =\> :get,  
:search\_all =\> :post, :search\_my =\> :post } do |projects|

And here in above resources is projects as well as the local variable  
also is |projects| So Is it not a problem? What does the above mean

Sijo
