Shallow nested Rails routing with :as - ruby-on-rails

I want:
Every projectpart to belong to a
project.
Every solution to belong to a
projectart (and to a project through
that projectpart).
Every image to belong to a solution
(and to a project and a projectpart
through that solution.)
Every document to belong to a
solution (and to a project and a
projectpart through that solution.)
Every URL to be as short as simple as
possible.
Every case of "projectpart" to appear
as "part" in every URL. (I couldn't
call the model "part" on Heroku.)
Can anyone tell me why this...
ActionController::Routing::Routes.draw do |map|
map.resources :projects, :shallow => true do |project|
project.resources :projectparts do |part|
part.resources :solutions do |solution|
solution.resources :images
solution.resources :documents
end
end
end
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
...is leaving a whole bunch of cases of "projectpart" in my URLs...
steven-nobles-imac-200:drominay steven$ rake routes
(in /Users/steven/Drominay)
projects GET /projects {:controller=>"projects", :action=>"index"}
formatted_projects GET /projects.:format {:controller=>"projects", :action=>"index"}
POST /projects {:controller=>"projects", :action=>"create"}
POST /projects.:format {:controller=>"projects", :action=>"create"}
new_project GET /projects/new {:controller=>"projects", :action=>"new"}
formatted_new_project GET /projects/new.:format {:controller=>"projects", :action=>"new"}
edit_project GET /projects/:id/edit {:controller=>"projects", :action=>"edit"}
formatted_edit_project GET /projects/:id/edit.:format {:controller=>"projects", :action=>"edit"}
project GET /projects/:id {:controller=>"projects", :action=>"show"}
formatted_project GET /projects/:id.:format {:controller=>"projects", :action=>"show"}
PUT /projects/:id {:controller=>"projects", :action=>"update"}
PUT /projects/:id.:format {:controller=>"projects", :action=>"update"}
DELETE /projects/:id {:controller=>"projects", :action=>"destroy"}
DELETE /projects/:id.:format {:controller=>"projects", :action=>"destroy"}
project_projectparts GET /projects/:project_id/projectparts {:controller=>"projectparts", :action=>"index"}
formatted_project_projectparts GET /projects/:project_id/projectparts.:format {:controller=>"projectparts", :action=>"index"}
POST /projects/:project_id/projectparts {:controller=>"projectparts", :action=>"create"}
POST /projects/:project_id/projectparts.:format {:controller=>"projectparts", :action=>"create"}
new_project_projectpart GET /projects/:project_id/projectparts/new {:controller=>"projectparts", :action=>"new"}
formatted_new_project_projectpart GET /projects/:project_id/projectparts/new.:format {:controller=>"projectparts", :action=>"new"}
edit_projectpart GET /projectparts/:id/edit {:controller=>"projectparts", :action=>"edit"}
formatted_edit_projectpart GET /projectparts/:id/edit.:format {:controller=>"projectparts", :action=>"edit"}
projectpart GET /projectparts/:id {:controller=>"projectparts", :action=>"show"}
formatted_projectpart GET /projectparts/:id.:format {:controller=>"projectparts", :action=>"show"}
PUT /projectparts/:id {:controller=>"projectparts", :action=>"update"}
PUT /projectparts/:id.:format {:controller=>"projectparts", :action=>"update"}
DELETE /projectparts/:id {:controller=>"projectparts", :action=>"destroy"}
DELETE /projectparts/:id.:format {:controller=>"projectparts", :action=>"destroy"}
projectpart_solutions GET /projectparts/:projectpart_id/solutions {:controller=>"solutions", :action=>"index"}
formatted_projectpart_solutions GET /projectparts/:projectpart_id/solutions.:format {:controller=>"solutions", :action=>"index"}
POST /projectparts/:projectpart_id/solutions {:controller=>"solutions", :action=>"create"}
POST /projectparts/:projectpart_id/solutions.:format {:controller=>"solutions", :action=>"create"}
new_projectpart_solution GET /projectparts/:projectpart_id/solutions/new {:controller=>"solutions", :action=>"new"}
formatted_new_projectpart_solution GET /projectparts/:projectpart_id/solutions/new.:format {:controller=>"solutions", :action=>"new"}
edit_solution GET /solutions/:id/edit {:controller=>"solutions", :action=>"edit"}
formatted_edit_solution GET /solutions/:id/edit.:format {:controller=>"solutions", :action=>"edit"}
solution GET /solutions/:id {:controller=>"solutions", :action=>"show"}
formatted_solution GET /solutions/:id.:format {:controller=>"solutions", :action=>"show"}
PUT /solutions/:id {:controller=>"solutions", :action=>"update"}
PUT /solutions/:id.:format {:controller=>"solutions", :action=>"update"}
DELETE /solutions/:id {:controller=>"solutions", :action=>"destroy"}
DELETE /solutions/:id.:format {:controller=>"solutions", :action=>"destroy"}
solution_images GET /solutions/:solution_id/images {:controller=>"images", :action=>"index"}
formatted_solution_images GET /solutions/:solution_id/images.:format {:controller=>"images", :action=>"index"}
POST /solutions/:solution_id/images {:controller=>"images", :action=>"create"}
POST /solutions/:solution_id/images.:format {:controller=>"images", :action=>"create"}
new_solution_image GET /solutions/:solution_id/images/new {:controller=>"images", :action=>"new"}
formatted_new_solution_image GET /solutions/:solution_id/images/new.:format {:controller=>"images", :action=>"new"}
edit_image GET /images/:id/edit {:controller=>"images", :action=>"edit"}
formatted_edit_image GET /images/:id/edit.:format {:controller=>"images", :action=>"edit"}
image GET /images/:id {:controller=>"images", :action=>"show"}
formatted_image GET /images/:id.:format {:controller=>"images", :action=>"show"}
PUT /images/:id {:controller=>"images", :action=>"update"}
PUT /images/:id.:format {:controller=>"images", :action=>"update"}
DELETE /images/:id {:controller=>"images", :action=>"destroy"}
DELETE /images/:id.:format {:controller=>"images", :action=>"destroy"}
solution_documents GET /solutions/:solution_id/documents {:controller=>"documents", :action=>"index"}
formatted_solution_documents GET /solutions/:solution_id/documents.:format {:controller=>"documents", :action=>"index"}
POST /solutions/:solution_id/documents {:controller=>"documents", :action=>"create"}
POST /solutions/:solution_id/documents.:format {:controller=>"documents", :action=>"create"}
new_solution_document GET /solutions/:solution_id/documents/new {:controller=>"documents", :action=>"new"}
formatted_new_solution_document GET /solutions/:solution_id/documents/new.:format {:controller=>"documents", :action=>"new"}
edit_document GET /documents/:id/edit {:controller=>"documents", :action=>"edit"}
formatted_edit_document GET /documents/:id/edit.:format {:controller=>"documents", :action=>"edit"}
document GET /documents/:id {:controller=>"documents", :action=>"show"}
formatted_document GET /documents/:id.:format {:controller=>"documents", :action=>"show"}
PUT /documents/:id {:controller=>"documents", :action=>"update"}
PUT /documents/:id.:format {:controller=>"documents", :action=>"update"}
DELETE /documents/:id {:controller=>"documents", :action=>"destroy"}
DELETE /documents/:id.:format {:controller=>"documents", :action=>"destroy"}
/:controller/:action/:id
/:controller/:action/:id.:format
...and yet is not generating basic URL helpers, like this?
undefined method `project_projectpart_path' for #<ActionView::Base:0x3438ffc> (ActionView::TemplateError)
BTW, everything except changing "projectpart" to "part" in every URL was working fine with this more verbose syntax:
ActionController::Routing::Routes.draw do |map|
map.resources :projects, :has_many => :projectparts
map.resources :projects, :has_many => :solutions
map.resources :projects, :has_many => :images
map.resources :projects, :has_many => :documents
map.resources :projectparts, :has_many => :solutions
map.resources :projectparts, :has_many => :images
map.resources :projectparts, :has_many => :documents
map.resources :solutions, :has_many => :images
map.resources :solutions, :has_many => :documents
map.resources :images
map.resources :documents
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end

The answer to your question about route generation is :shallow => true
Providing the shallow option will create longer routes for collection methods of the inner resource(s), while providing shallow routes for member methods of those nested resource(s). Take a closer look at the routes created and you'll see this.
Essentially routes that need an id (edit,update,show,destroy) will the short one containing only the inner most resource . Routes that don't need an id(index,new) will be slightly longer, containing the immediate parent.
You don't need project_projectpart_path because the project in project_projectpart can be implied from the project part. Instead just use projectpart_path for existing project parts.
Your second example provides those missing routes because it never gives the shallow option.
Changing 'projectpart' to 'part' in urls is as simple as adding the :as option in it's definition. Sorry it won't work with the shorthand :has_many version
map.resources :projects, :shallow => true do |project|
project.resources :projectparts, :as => "part" do |part|
part.resources :solutions do |solution|
solution.resources :images
solution.resources :documents
end
end
end

Related

Sophisticated route and url generation in Rails

I have a group model which has_many article model. And I want to use the following url pattern "{group_id}/{article_id}".
so I wrote these route codes:
resource :groups do
resource :articles
end
match ':group_id/:id(.:format)', :to => 'articles#show', :as => :article
match ':id', :to => 'groups#show', :as => :group
But rails fail to generate correct url for group records and article records. How can I replace the automatic generated article_path and group_path to match my routes?
You're running into problems because you aren't watching out for pluralization. When you define a singular resource route, Rails doesn't treat it as a collection where you would refer to each member with an id. You instead want a plural resources for both groups and articles:
resources :groups do
resources :articles
end
Generates the following routes:
group_articles GET /groups/:group_id/articles(.:format) {:action=>"index", :controller=>"articles"}
POST /groups/:group_id/articles(.:format) {:action=>"create", :controller=>"articles"}
new_group_article GET /groups/:group_id/articles/new(.:format) {:action=>"new", :controller=>"articles"}
edit_group_article GET /groups/:group_id/articles/:id/edit(.:format) {:action=>"edit", :controller=>"articles"}
group_article GET /groups/:group_id/articles/:id(.:format) {:action=>"show", :controller=>"articles"}
PUT /groups/:group_id/articles/:id(.:format) {:action=>"update", :controller=>"articles"}
DELETE /groups/:group_id/articles/:id(.:format) {:action=>"destroy", :controller=>"articles"}
groups GET /groups(.:format) {:action=>"index", :controller=>"groups"}
POST /groups(.:format) {:action=>"create", :controller=>"groups"}
new_group GET /groups/new(.:format) {:action=>"new", :controller=>"groups"}
edit_group GET /groups/:id/edit(.:format) {:action=>"edit", :controller=>"groups"}
group GET /groups/:id(.:format) {:action=>"show", :controller=>"groups"}
PUT /groups/:id(.:format) {:action=>"update", :controller=>"groups"}
DELETE /groups/:id(.:format) {:action=>"destroy", :controller=>"groups"}
If you want to leave off the groups and articles segments you can pass :path => '' to each of the resources definitions, but you are going to have to tread carefully because any request to http://example.com/1/2 will map to an article under groups and be uninformative to end users and bots alike.

Rails routes error troubleshooting

I'm getting a weird error when I try to link to the show_members action
Routing Error
No route matches "/groups/1/show_members"
#routes.rb
get 'groups/:id/members' => 'groups#show_members'
#groups_controller.rb
def show_members
When I run rake routes I get this:
#rake routes
groups GET /groups(.:format) {:controller=>"groups", :action=>"index"}
groups POST /groups(.:format) {:controller=>"groups", :action=>"create"}
new_group GET /groups/new(.:format) {:controller=>"groups", :action=>"new"}
edit_group GET /groups/:id/edit(.:format) {:controller=>"groups", :action=>"edit"}
group GET /groups/:id(.:format) {:controller=>"groups", :action=>"show"}
group PUT /groups/:id(.:format) {:controller=>"groups", :action=>"update"}
group DELETE /groups/:id(.:format) {:controller=>"groups", :action=>"destroy"}
group_join GET /groups/join(.:format) {:controller=>"groups", :action=>"join"}
group_remove_user PUT /groups/remove_user(.:format){:controller=>"groups", :action=>"remove_user"}
GET /groups/:id/members(.:format){:controller=>"groups", :action=>"show_members"}
UPDATE:
But all I want the show_members action to do is show all the users within that group. I want the user functionality and paths to remain the same. And now the show_members action routes to group, the same as show. In my groups controller, I split the default show group action into three pages, one for the group profile which is show, one for the members in that group which goes to show_members, and one for the news page, which will go to show_news when i get to it.
#groups_controller.rb
def show_members
#group = Group.find(params[:id])
#members = #group.users
#group_admin = User.find(#group.group_admin)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => #group }
end
end
#rake routes
group_join GET /groups/:group_id/join(.:format) {:controller=>"groups", :action=>"join"}
group_remove_user PUT /groups/:group_id/remove_user(.:format) {:controller=>"groups", :action=>"remove_user"}
group GET /groups/:group_id/:id/members(.:format) {:controller=>"groups", :action=>"show_members"}
group_users GET /groups/:group_id/users(.:format) {:controller=>"users", :action=>"index"}
group_user GET /groups/:group_id/users/:id(.:format) {:controller=>"users", :action=>"show"}
I WANT THIS new_user_session GET /users/sign_in(.:format) {:controller=>"devise/sessions", :action=>"new"}
INSTEAD OF THIS new_user_group_session GET /users/groups/:group_id/sign_in(.:format) {:controller=>"devise/sessions", :action=>"new"}
user_group_session POST /users/groups/:group_id/sign_in(.:format) {:controller=>"devise/sessions", :action=>"create"}
destroy_user_group_session GET /users/groups/:group_id/sign_out(.:format) {:controller=>"devise/sessions", :action=>"destroy"}
user_group_password POST /users/groups/:group_id/password(.:format) {:controller=>"devise/passwords", :action=>"create"}
new_user_group_password GET /users/groups/:group_id/password/new(.:format) {:controller=>"devise/passwords", :action=>"new"}
edit_user_group_password GET /users/groups/:group_id/password/edit(.:format) {:controller=>"devise/passwords", :action=>"edit"}
user_group_password PUT /users/groups/:group_id/password(.:format) {:controller=>"devise/passwords", :action=>"update"}
user_group_registration POST /users/groups/:group_id(.:format) {:controller=>"users/registrations", :action=>"create"}
new_user_group_registration GET /users/groups/:group_id/sign_up(.:format) {:controller=>"users/registrations", :action=>"new"}
edit_user_group_registration GET /users/groups/:group_id/edit(.:format) {:controller=>"users/registrations", :action=>"edit"}
user_group_registration PUT /users/groups/:group_id(.:format) {:controller=>"users/registrations", :action=>"update"}
user_group_registration DELETE /users/groups/:group_id(.:format) {:controller=>"users/registrations", :action=>"destroy"}
user_group_confirmation POST /users/groups/:group_id/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"create"}
new_user_group_confirmation GET /users/groups/:group_id/confirmation/new(.:format) {:controller=>"devise/confirmations", :action=>"new"}
user_group_confirmation GET /users/groups/:group_id/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"show"}
groups GET /groups(.:format) {:controller=>"groups", :action=>"index"}
groups POST /groups(.:format) {:controller=>"groups", :action=>"create"}
new_group GET /groups/new(.:format) {:controller=>"groups", :action=>"new"}
edit_group GET /groups/:id/edit(.:format) {:controller=>"groups", :action=>"edit"}
group GET /groups/:id(.:format) {:controller=>"groups", :action=>"show"}
group PUT /groups/:id(.:format) {:controller=>"groups", :action=>"update"}
group DELETE /groups/:id(.:format) {:controller=>"groups", :action=>"destroy"}
#routes.rb
resources :groups do
get 'join' => 'groups#join'
put 'remove_user' => 'groups#remove_user'
get ':id/members' => 'groups#show_members'
resources :users, :only => [:index, :show]
devise_for :users, :controllers => { :registrations => "users/registrations" }
end
Rails is correct when it says that no route matches /groups/1/show_members - your routes.rb is creating a route for something like /groups/1/members (without the "show_")
You'll need to change routes.rb to look like:
get 'groups/:id/show_members` => 'groups#show_members'
Well the problem is of course you haven't done everything right.
resources :groups do |group|
group.resources :members
end
link_to #member.name, [#group, #member]
Magic.
Now reading the guide would be a very good idea.
http://guides.rubyonrails.org/routing.html

Rails route which disappears in application but is present in rake routes

I have a mystic problem....
In my routes.rb I have some routes defined and for exemple
resources :projects, :except => [:destroy] do
get :edit_flyer, :on => :member
get :guests, :on => :member
end
If I run a rake routes, I get
edit_flyer_project GET /projects/:id/edit_flyer(.:format) {:controller=>"projects", :action=>"edit_flyer"}
guests_project GET /projects/:id/guests(.:format) {:controller=>"projects", :action=>"guests"}
GET /projects(.:format) {:controller=>"projects", :action=>"index"}
projects POST /projects(.:format) {:controller=>"projects", :action=>"create"}
new_project GET /projects/new(.:format) {:controller=>"projects", :action=>"new"}
GET /projects/:id(.:format) {:controller=>"projects", :action=>"show"}
project PUT /projects/:id(.:format) {:controller=>"projects", :action=>"update"}
edit_project GET /projects/:id/edit(.:format) {:controller=>"projects", :action=>"edit"}
As you can see, the show action is defined.
But in my rails applications, the route show is not defined.
I add this in my application controller just to monitored the routes.
before_filter :zba
def zba
ActionController::Routing::Routes.named_routes.routes.each do |name, route|
puts "%20s: %s" % [name, route]
end
exit
end
And it appears that the route action is not defined ....
Then, I tryed to clean my routes.rb, like removing all my back namespace, and magically it works.
It seems to be a bug, or I don't know what appened.
Have you any idea how to debug this ? I also tryed to remove plugin/gems. No change.
I run with Rails3.rc with ruby 1.8.7 !
Thanks for your help !
Try this
resources :projects, :except => [:destroy] do
member do
get :edit_flyer
get :guests
end
end

Nested routes in Rails with an alias

I have a primary model for my project, Place.rb with a places_controller, and I've currently got it exactly the way I want for the users end of my project. With a nested photos controller, review, etc.
I want now to create a management resource which is mostly just an alias for Places, with its own nested resources, some of them overlapping, some of them new.
I tried creating a new controller for it called Manage, but I'm having a hard time with routes. I'm not quite sure the hangup is, but I figure I'm doing something very wrong. I had little difficulty when I was using Places as controller to a real model and nesting other resources below it.
But for example trying to create a new record for a nested resource doesn't route correctly.
I can get a route path like new_manage_room_path(#place) for a link_to to work fine. But
for creating a New announcement in a form:
form_for manage_room_path(#place) doesn't work correctly given a valid id. I've tried many other combinations supplying the object and :url.
Should I avoid using a separate controller and just create an alias or what is the special routing for this purpose?
map.resources :manage, :collection => { :upcoming => [ :post, :get ], :pending => [ :post, :get ] } do |manage|
manage.resources :rooms
manage.resources :room_rates, :as => :rates
manage.resources :availables
manage.resources :manage_bookings, :as => :bookings
end
map.resources :places do |place|
place.resources :bookings
place.resources :photos, :collection => { :sort => :post }
place.resources :reviews, :only => [ :index, :show ]
end
manage_rooms GET /manage/:manage_id/rooms(.:format) {:controller=>"rooms", :action=>"index"}
POST /manage/:manage_id/rooms(.:format) {:controller=>"rooms", :action=>"create"}
new_manage_room GET /manage/:manage_id/rooms/new(.:format) {:controller=>"rooms", :action=>"new"}
edit_manage_room GET /manage/:manage_id/rooms/:id/edit(.:format) {:controller=>"rooms", :action=>"edit"}
manage_room GET /manage/:manage_id/rooms/:id(.:format) {:controller=>"rooms", :action=>"show"}
PUT /manage/:manage_id/rooms/:id(.:format) {:controller=>"rooms", :action=>"update"}
DELETE /manage/:manage_id/rooms/:id(.:format) {:controller=>"rooms", :action=>"destroy"}
manage_room_rates GET /manage/:manage_id/rates(.:format) {:controller=>"room_rates", :action=>"index"}
POST /manage/:manage_id/rates(.:format) {:controller=>"room_rates", :action=>"create"}
new_manage_room_rate GET /manage/:manage_id/rates/new(.:format) {:controller=>"room_rates", :action=>"new"}
edit_manage_room_rate GET /manage/:manage_id/rates/:id/edit(.:format) {:controller=>"room_rates", :action=>"edit"}
manage_room_rate GET /manage/:manage_id/rates/:id(.:format) {:controller=>"room_rates", :action=>"show"}
PUT /manage/:manage_id/rates/:id(.:format) {:controller=>"room_rates", :action=>"update"}
DELETE /manage/:manage_id/rates/:id(.:format) {:controller=>"room_rates", :action=>"destroy"}
manage_availables GET /manage/:manage_id/availables(.:format) {:controller=>"availables", :action=>"index"}
POST /manage/:manage_id/availables(.:format) {:controller=>"availables", :action=>"create"}
new_manage_available GET /manage/:manage_id/availables/new(.:format) {:controller=>"availables", :action=>"new"}
edit_manage_available GET /manage/:manage_id/availables/:id/edit(.:format) {:controller=>"availables", :action=>"edit"}
manage_available GET /manage/:manage_id/availables/:id(.:format) {:controller=>"availables", :action=>"show"}
PUT /manage/:manage_id/availables/:id(.:format) {:controller=>"availables", :action=>"update"}
DELETE /manage/:manage_id/availables/:id(.:format) {:controller=>"availables", :action=>"destroy"}
manage_manage_bookings GET /manage/:manage_id/bookings(.:format) {:controller=>"manage_bookings", :action=>"index"}
POST /manage/:manage_id/bookings(.:format) {:controller=>"manage_bookings", :action=>"create"}
new_manage_manage_booking GET /manage/:manage_id/bookings/new(.:format) {:controller=>"manage_bookings", :action=>"new"}
edit_manage_manage_booking GET /manage/:manage_id/bookings/:id/edit(.:format) {:controller=>"manage_bookings", :action=>"edit"}
manage_manage_booking GET /manage/:manage_id/bookings/:id(.:format) {:controller=>"manage_bookings", :action=>"show"}
PUT /manage/:manage_id/bookings/:id(.:format) {:controller=>"manage_bookings", :action=>"update"}
DELETE /manage/:manage_id/bookings/:id(.:format) {:controller=>"manage_bookings", :action=>"destroy"}
pending_manage POST /manage/pending(.:format) {:controller=>"manage", :action=>"pending"}
GET /manage/pending(.:format) {:controller=>"manage", :action=>"pending"}
upcoming_manage POST /manage/upcoming(.:format) {:controller=>"manage", :action=>"upcoming"}
GET /manage/upcoming(.:format) {:controller=>"manage", :action=>"upcoming"}
manage_index GET /manage(.:format) {:controller=>"manage", :action=>"index"}
POST /manage(.:format) {:controller=>"manage", :action=>"create"}
new_manage GET /manage/new(.:format) {:controller=>"manage", :action=>"new"}
edit_manage GET /manage/:id/edit(.:format) {:controller=>"manage", :action=>"edit"}
manage GET /manage/:id(.:format) {:controller=>"manage", :action=>"show"}
PUT /manage/:id(.:format) {:controller=>"manage", :action=>"update"}
DELETE /manage/:id(.:format) {:controller=>"manage", :action=>"destroy"}
Try:
<% form_for #new_room, :url => manage_rooms_path(#place) do |f| %>
or maybe it will work this way:
<% form_for manage_rooms_path(#place, #new_room) do |f| %>
#new_room is new instance of Room model, so in controller add:
#new_room = Room.new

Nested routing

How do I write a route that maps a path like this?
/powerusers/bob/article-title
This is what I got so far:
map.resources :users, :as => "powerusers" do |users|
users.resources :articles, :as => ''
end
This gives me the following route:
/powerusers/:user_id//:id
How do I get rid of the double backslah? /powerusers/admin//first-article?
Best regards.
Asbjørn Morell
Ok, if you don't want the intermediate nested resource (/articles) I wouldn't use the map.resources at all.
Try:
map.connect '/powerusers/:user_id/:article_title', :controller => 'articles', :action => 'view_by_title'
If I add...
map.resources :users, :as => "powerusers" do |users|
users.resources :entries, :as => 'article-title'
end
I get the routes below, which include the one you want...
(Substitute "articles" for "entries" for your situation.)
GET /powerusers(.:format) {:controller=>"users", :action=>"index"}
POST /powerusers(.:format) {:controller=>"users", :action=>"create"}
GET /powerusers/new(.:format) {:controller=>"users", :action=>"new"}
GET /powerusers/:id/edit(.:format) {:controller=>"users", :action=>"edit"}
GET /powerusers/:id(.:format) {:controller=>"users", :action=>"show"}
PUT /powerusers/:id(.:format) {:controller=>"users", :action=>"update"}
DELETE /powerusers/:id(.:format) {:controller=>"users", :action=>"destroy"}
user_entries GET /powerusers/:user_id/article-title(.:format) {:controller=>"entries", :action=>"index"}
POST /powerusers/:user_id/article-title(.:format) {:controller=>"entries", :action=>"create"}
new_user_entry GET /powerusers/:user_id/article-title/new(.:format) {:controller=>"entries", :action=>"new"}
edit_user_entry GET /powerusers/:user_id/article-title/:id/edit(.:format) {:controller=>"entries", :action=>"edit"}
user_entry GET /powerusers/:user_id/article-title/:id(.:format) {:controller=>"entries", :action=>"show"}
PUT /powerusers/:user_id/article-title/:id(.:format) {:controller=>"entries", :action=>"update"}
DELETE /powerusers/:user_id/article-title/:id(.:format) {:controller=>"entries", :action=>"destroy"}
Instead of nesting, would this work?
map.resources :users, :as => "powerusers"
map.resources :articles, :path_prefix => '/powerusers/:user_id'
I think it won't but a quick test would tell better :)

Resources