d2kagw
d2kagw

Reputation: 807

Namespaced routes

I must be missing something with this rather trivial routes implementation in Rails 3.

I have a namespaced route like so:

namespace 'dashboard' do
  get 'download', to: "Index#download"
end

If I run rake routes I see:

dashboard_download  GET  /dashboard/download(.:format) {:action=>"download", :controller=>"dashboard/Index"}

The URL is super, that's exactly what I want (and will have many more matches in the namespace), but the controller is wrong. It should just be Index, not dashboard/Index.

Is there any way of fixing this? Or is that the wrong way to implement that style of route?

Cheers.

Upvotes: 0

Views: 157

Answers (1)

Pan Thomakos
Pan Thomakos

Reputation: 34340

To remove the module prefix do this:

scope '/dashboard' do
  get 'download', to: "Index#download"
end

You can find more information and alternatives here.

Upvotes: 2

Related Questions