clintpachl wrote:> $ ruby script/generate controller NewAccount::Business
> $ ruby script/generate controller NewAccount::Personal
> $ ruby script/generate controller NewAccount
>
> This doesn''t work because the NewAccountController class gets all
the
> incoming requests (URLs prefixed with "new_account"). What I
would like
> is a conventional way for the following URLs to work without using
> routes.rb.
>
> Call index action in NewAccountController:
> http://host.net/new_account
>
> Call index action in NewAccount::BusinessController:
> http://host.net/new_account/business
>
> Call index action in NewAccount::PersonalController:
> http://host.net/new_account/personal
>
> What I would like to have happen is have the NewAccountController
> render a page with links to the scoped controllers, ie.
> NewAccount::[Business|Personal]Controller. Basically, the URL at
> /new_account will give an overview of the Personal and Business
> accounts and provide links to each controller''s index action.
>
> It seems like there may be a better way. Any help is much appreciated.
>
> -pachl
>
> Reply
The easiest way to do this is probably to create new controllers normally for
Business and Personal and set up routes to make them function hierarchically.
For instance, you might say:
map.connect ''new_account/business/:action/:id'', :controller
=> ''business''
map.connect ''new_account/personal/:action/:id'', :controller
=> ''personal''
Alternately, you could write a method has_children that you call in
NewAccountController, that takes the names of the child controllers and
dynamically generates methods that will render the correct pages.
-Nex3
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---