How to get the path name of route .

Hi, everyone,

I set a url as resource :posts, :path => "/admin/posts", So, how can i get this partial path like this 'admin' ? I just want to get this word 'admin' in controller.

thank you.

You're probably better off just namespacing 'admin' in your routes.

namespace :admin do   resources :posts end

Then you'll get "admin/posts" for admin_posts_path

For your controller, you'll just need to prefix the namespace

class Admin::PostsController < ApplicationController

Just remember that you'll need to keep your controllers and views in a separate 'admin' folder.

Hope this helps.