繁体   English   中英

Rails 4:改变设计路线

[英]Rails 4: Changing devise routes

我正在使用Devise 3.4.1并且我有一个模型谁属于设计User (称为resume 。而不是localhost:3000/resume/new我想改变它做localhost:3000/users/resume/new 。我尝试过下列:

namespace :users do
    resources :resume, except: [:index]
  end

但它显示:

ActionController::RoutingError at /user/resume/new
uninitialized constant User::ResumeController

控制器是以下代码:

class ResumeController < ApplicationController

    before_action :find_resume, only: [:show, :edit, :update, :destroy]
    before_action :authenticate_user!, except: [:index, :show]

    def index
        @resumes = Resume.all
    end

    def show
    end

    def new
        @resume = current_user.resumes.build
    end

    def create
        @resume = current_user.resumes.build(resume_params)

        if @resume.save
            redirect_to @resume, notice: "resume was successfully created"
        else
            render 'new'
        end
    end

    def edit
    end

    def update
        if @resume.update(resume_params)
            redirect_to @resume, notice: "resume was successfully updated"
        else
            render 'edit'
        end
    end

    def destroy
        @resume.destroy
        redirect_to root_path
    end

    private

    def resume_params
        params.require(:resume).permit(:description, :skills, 
                                        jobs_attributes: [:id, :company_name, :location, :title, :duration, :description, :_destroy], 
                                        educations_attributes: [:id, :establishment, :Location, :majored, :duration, :description, :_destroy] )
    end

    def find_resume
        @resume = resume.find(params[:id])
    end
end

UPDATE

在User(routes.rb)中添加“s”后我得到了同样的错误:这是我的路线:

在此输入图像描述

尝试这个:

devise_scope :user do
  get 'resume/new' => 'resumes#new', as: 'new_resume'
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM