2015-11-01 68 views
1

在我的項目,每當我嘗試註冊一個新用戶,我得到的錯誤設計註冊記憶控制器santize_for_mass_assignment錯誤軌道4

NoMethodError - super: no superclass method `sanitize_for_mass_assignment' for #<User:0x007f130c708f20>: 
    activemodel (4.2.1) lib/active_model/attribute_methods.rb:430:in `method_missing' 
    strong_parameters (0.1.4) lib/active_model/forbidden_attributes_protection.rb:8:in `sanitize_for_mass_assignment' 
    activerecord (4.2.1) lib/active_record/attribute_assignment.rb:33:in `assign_attributes' 
    activerecord (4.2.1) lib/active_record/core.rb:559:in `init_attributes' 
    activerecord (4.2.1) lib/active_record/core.rb:281:in `initialize' 
    activerecord (4.2.1) lib/active_record/inheritance.rb:61:in `new' 

在我的項目,我做了以下

user.rb

class User < ActiveRecord::Base 

    # Include default devise modules. Others available are: 
    # :confirmable, :lockable, :timeoutable and :omniauthable 
    devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :registerable 

end 

我創建的是定製的註冊控制器如下:

class RegistrationsController < Devise::RegistrationsController 

    private 

    def sign_up_params 
    params.require(:user).permit(:email, :password, :password_confirmation) 
    end 

    def account_update_params 
    params.require(:user).permit(:email, :password, :password_confirmation, :current_password) 
    end 
end 

users_controller.rb

class UsersController < ApplicationController 

    def index 

    end 

    private 
    def sign_up_params 
     params.require(:user).permit(:email, :password, :password_confirmation) 
    end 
    end 
end 

我很困惑,爲什麼我得到這個錯誤,我使用的鐵軌4.2.1和3.5.2制定

任何幫助表示讚賞

回答

0

如果您正面臨這個問題,你已經安裝gem'strong_parameters'請刪除它,因爲它已被添加到ActiveModel和ActiveController自Rails 4.0以來。文檔讓我感到困惑,所以我添加了寶石,並導致我的錯誤。

相關問題