我正在尝试将此方法添加到一个安静的控制器(也有以下工作方法:index,:new,:create,:edit,:update和:destroy):
class Admin::ClassSectionsController < ApplicationController
def clone
@class_section = ClassSection.find(params[:id])
@class_section = ClassSection.new(@class_section.attributes)
render :new
end
end
以下是config / routes.rb:
Utg::Application.routes.draw do
devise_for :users
root to: "home#index"
namespace :admin do
resources :class_sections, except: [:show]
end
resources :class_sections, only: [:index, :show]
end
如何为'admin / class_section /:id / clone'添加路由?
答案 0 :(得分:1)
namespace :admin do
get "class_sections/:id/clone", to: "class_sections#clone", as: "class_sections_clone"
end