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.
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs