小编Thr*_*esh的帖子

使用devise进行注册时ActiveModel :: ForbiddenAttributesError

我正在使用设计来注册我的用户.我正在自定义注册控制器的创建操作,但是每当我尝试创建任何新用户时,它都被拒绝,我得到上述错误.我知道我必须允许所需的参数,我这样做我不明白为什么我一直收到错误.到目前为止,贝娄是我的考验.

#user model
class User < ActiveRecord::Base
    devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable, :confirmable
    belongs_to :country
    #rest of the code
end

## Custom registeration controller
class RegistrationsController < Devise::RegistrationsController
    def create
        @user = User.new(params[:user])
        if @user.save
            sign_in(@user, bypass: true)
            redirect_to user_employee_steps_path(@user),
    notice: 'A confirmation email was sent to your email, please complete your profile
            and confirm your account to start looking for potential employees'
        else
            render 'new'
        end
    end
end

#new.html.erb the view for the registration sign up
<h2>Sign …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails devise strong-parameters ruby-on-rails-4

3
推荐指数
1
解决办法
3129
查看次数