Re: RESTful URL quesiton

Tyler MacDonald
Wed, 04 Apr 2007 02:26:57 -0000

Here''s what I got so far, but it''s far from perfect:

In routes.rb:

  map.connect ''records/:rcontroller/:id'',
    :controller => ''records'', :action =>
''route''

  map.connect ''records/:rcontroller/:raction/:id'',
    :controller => ''records'', :action =>
''route''

  map.connect ''records/:rcontroller'',
    :controller => ''records'', :action =>
''route''

In a "records" controller:

  def route
    render_component :controller => "records/" +
params[:rcontroller],
      :action => params[:raction],
      :id => params[:id]
  end

That seems to route things to the right place, but it also seems like
overkill for such a simple thing as organizing my controllers...???

	- Tyler


Tyler MacDonald <google.com-oTuY4Vk9bUDG8MNy1oJpyw@public.gmane.org>
wrote:
>
>
> Lee <urbansprawl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >
> > Maybe design this differently?
> >
> > map.resources :records do |record|
> >   record.resources :names
> >   record.resources :monkeys
> > end
>
>   What I want is to have the "names" and "monkeys"
controllers in
> app/controllers/records; eg app/controllers/records/name.rb with somethin
> like:
>
>   class Records::NameController < RecordsController
>
>   etc..
>
>   But yes, most of these things will probably be resources. :)
>
> 	Thanks,
> 		Tyler
>
> >

--