how to set up and use a Rails routes prefix

后端 未结 7 914
北海茫月
北海茫月 2021-02-05 07:39

When running rake routes I see:

 Prefix   Verb   URI Pattern                                       Controller#Action
 articles  GET    /articles(.:format)               


        
7条回答
  •  盖世英雄少女心
    2021-02-05 08:00

    You can also use route scopes for it. In your routes.rb file:

    Rails.application.routes.draw do
    
      # Any other routes here
      scope 'admin' do
        resources :articles
      end
    end
    

    /admin/articles and all the other CRUD related routes will work with link_to, form submit controls, etc.

提交回复
热议问题