I’ve got some problems migrating from rails2 to rails3: I have some
controllers in a subdirectory, and I want to access them in a
non-restful/resourceful way.
Previously I just created a controller in /util, prefixed the class name
with Util:: and it worked, that is /util/controller_name/action_name was
routed properly.
I was trying various approaches with :namespace, e.g.:
namespace :util do
match ‘:controller(/:action(/:id(.:format)))’
end
but that throws an exception during boot: “:controller segment is not
allowed within a namespace block”
Ah, I was looking for a proper :namespace usage. This indeed helps,
though now I have:
match ‘:controller(/:action(/:id))’, :controller => /tabs/[^/]+/
match ‘:controller(/:action(/:id))’, :controller => /util/[^/]+/
match ‘:controller(/:action(/:id(.:format)))’
which may not seem obvious at first. But you just need a way to tell
Rails to look beyond the first / when finding the controller name.
Thanks,
Adam
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.