# Rails3 routes

**URL:** <https://www.ruby-forum.com/t/rails3-routes/195797>\
**Category:** Rails\
**Created:** [September 30, 2010, 10:12am UTC](https://www.ruby-forum.com/t/rails3-routes/195797 "2010-09-30T10:12:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e8c25b/32.png) [@bingo](https://www.ruby-forum.com/u/bingo)\
**Post date:** [September 30, 2010, 10:12am UTC](https://www.ruby-forum.com/t/rails3-routes/195797/1 "2010-09-30T10:12:04Z")

</div>

I’m migrating my app from Rails 2.3.8 to Rails 3.0.0 . But I’ve  
problems in converting my routes.rb which looks like this:

ActionController::Routing::Routes.draw do |map|

map.namespace(:admin) do |admin|  
admin.resources :participants  
admin.resources :communities, :has\_many =\> :participants  
admin.resources :organizations  
end

map.resources :memberships, :only =\> [:index]

begin  
RessourceData.all.each do |r|  
map.resources r.ressource.to\_sym, :path\_prefix =\>  
‘/’+r.namespace,  
:name\_prefix =\> r.namespace+’\_’, :controller =\> ‘messages’,  
:only =\> [:index, :show, :create, :update, :destroy],  
:collection =\> { :fifo =\> [:get, :post], :lifo =\>  
[:get, :post] }  
end  
rescue ActiveRecord::StatementInvalid  
Rails.logger.info “DB error: #{$!}”  
end

end

With this code I’m able to do dynamic routing: the dynamic routes  
where build out of the RessourceData model.  
I’ve tried to convert these routes into Rails3 routes like this:

Ecs2::Application.routes.draw do

namespace :admin do  
resources :participants  
resources :communities, :has\_many =\> :participants  
resources :organizations  
resources :ressources  
end  
resources :memberships, :only =\> [:index]

begin  
RessourceData.all.each do |r|  
namespace r.namespace.to\_sym do  
resources r.ressource.to\_sym, :controller =\> ‘messages’, :only  
=\> [:index, :show, :create, :update, :destroy] do  
collection do  
get ‘fifo’  
post ‘fifo’  
get ‘lifo’  
post ‘lifo’  
end  
end  
end  
end  
rescue ActiveRecord::StatementInvalid  
Rails.logger.info “DB error: #{$!}”  
end

But generated routes out of the RessourceData model aren’t correct,  
because the responsible controller is generated like “r.namespace/  
r.ressource” instead of just “messages”, e.g.

“vip/exercises” instead of simply “messages”

Any suggestions ?
