小编Pre*_*ika的帖子

得到错误因为无法自动加载常量UsersController

我在访问/users/newRails 4 时遇到错误Unable to autoload constant UsersController, expecting /app/controllers/users_controller.rb to define it.

这是控制器代码

    class UserController < ApplicationController
     def new
      @user = User.new
     end

     def create
      @user = User.new(params[:user]).permit(:email,  :password,:password_confirmation)

      respond_to do |format|
       if @user.save
        format.html { redirect_to new_user_path, notice: 'User was successfully created.' }
        format.json { render action: 'show', status: :created, location: @user }
       else
        format.html { render action: 'new' }
        format.json { render json: @user.errors, status: :unprocessable_entity }
       end
      end
    end 
  end
Run Code Online (Sandbox Code Playgroud)

我的观点new.html.erb是: …

ruby-on-rails

14
推荐指数
1
解决办法
2万
查看次数

标签 统计

ruby-on-rails ×1