views:

293

answers:

1

Hi All,

there are several places in my routes.rb file where I say:

map.resources :foo, :only => [:show, :index]

and I would like to be able to say:

map.resources :foo, :readonly => true

..or something of the like. I know this may seem kind of pointless, since it only saves a couple of characters, but I'd like to know how to do it so that I can add other more complicated options in the future.

Thx

-C

+1  A: 

Not quite what you're looking for, but you could save some typing with Object#with_options:

map.with_options(:only => [:show, :index]) do |readonly|
  readonly.resources :foo
  readonly.resources :bar
  ...
end

Otherwise, you're probably looking at monkey patching or subclassing ActionController::Routing::RouteSet::Mapper.

cpm
with_options helps, but, doesn't work the way I'd like with nested resources. thx for pointing me to the mapper class, after looking through it, I can tell that custom options will be no easy task. If I don't get a more complete answer, or figure it out myself soon, I'll accept this one.
Chris Drappier