Rails3 routes

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 ?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs