我用 rolify gem 制作了模型角色。但是控制器对命名空间 :admin :
class Admin::RolesController < ApplicationController
def index
@roles = Role.all
end
def new
@role = Role.new
end
def create
@role = Role.new(role_params)
respond_to do |format|
if @role.save
format.html { redirect_to admin_role_path(@role), notice: 'Роль создана.' }
format.json { render action: 'show', status: :created, location: @role }
else
format.html { render action: 'new' }
format.json { render json: @role.errors, status: :unprocessable_entity }
end
end
end
def show
@role = Role.find(params[:id])
end
def edit
@role = Role.find(params[:id])
end
def update
respond_to do |format|
if @role.update(role_params)
format.html { redirect_to admin_role_path(@role), notice: 'Роль обновлена.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @role.errors, status: :unprocessable_entity }
end
end
end
def destroy
@role = Role.find(params[:id])
@role.destroy
respond_to do |format|
format.html { redirect_to admin_roles_url }
format.json { head :no_content }
end
end
private
def set_role
@role = Role.find(params[:id])
end
def role_params
params.require(:role).permit(:name)
end
end
当我想更新角色时,我打开表单,编辑,单击提交并得到错误:
路由错误 没有路线匹配 [PATCH] "/admin/roles.4"
请帮我。