Ruby on rails rails设计中的UMPermited参数,即使参数允许(ted)
我有rails(6.0.2.2)项目和Desive(4.7.1),有两种类型的帐户:教师和学生。学生可以成功注册,但由于某种原因与老师有问题。当我尝试创建一个测试帐户时,我得到Ruby on rails rails设计中的UMPermited参数,即使参数允许(ted),ruby-on-rails,devise,Ruby On Rails,Devise,我有rails(6.0.2.2)项目和Desive(4.7.1),有两种类型的帐户:教师和学生。学生可以成功注册,但由于某种原因与老师有问题。当我尝试创建一个测试帐户时,我得到 Unpermitted parameter: :email 错误消息和我的信息未保存在数据库中 迁移: class DeviseCreateTeachers < ActiveRecord::Migration[6.0] def change create_table :teachers do |t| ## D
Unpermitted parameter: :email
错误消息和我的信息未保存在数据库中
迁移:
class DeviseCreateTeachers < ActiveRecord::Migration[6.0]
def change
create_table :teachers do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
t.string :username
t.string :name
t.string :neighborhood
t.integer :pet_skin
t.integer :pet_eyes
t.integer :pet_face
t.integer :pet_accessories
## Trackable
# t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.datetime :locked_at
t.timestamps null: false
end
add_index :teachers, :email, unique: true
add_index :teachers, :reset_password_token, unique: true
# add_index :teachers, :confirmation_token, unique: true
# add_index :teachers, :unlock_token, unique: true
end
end
将默认登录从电子邮件更改为用户名,但我认为这不是问题,因为学生同样可以创建帐户
谢谢你的帮助 @Tijana我不知道你是否已经检查过了。 链接如果没有,可能会有帮助
@Tijana我不知道你是否已经检查过这个。 链接如果没有,可能会有帮助
class TeacherController < ApplicationController
private
def sign_up_params
params.require(:teacher).permit(:email, :username, :name, :password, :password_confirmation, :neighborhood, :pet_skin, :pet_eyes, :pet_face)
end
def account_update_params
params.require(:teacher).permit(:username, :password, :password_confirmation, :current_password)
end
end
config.authentication_keys = [:username]