开发者

about rails route

开发者 https://www.devze.com 2023-01-24 20:51 出处:网络
if i use namespace :helpcenter do get \"hh/logout\" get \'hh/login\' end it will match the url helpcenter/hh/logout

if i use

namespace :helpcenter do
  get "hh/logout"
  get 'hh/login'
end

it will match the url helpcenter/hh/logout

my question is ho开发者_如何学Gow to let these method mapping to the url /hh/logout didn't contains the module name


You can use a scope to achieve this:

scope :module => 'helpcenter' do
  resources :articles
end

This will generate a mapping for /articles, /articles/new etc and not helpcenter/articles. It will however still route to the articles controller in the helpcenter namespace. e.g.: app/controllers/helpcenter/articles_controller.rb

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消