简体   繁体   English

Rails抛出未经许可的参数:使用Devise时出现名称错误

[英]Rails throwing Unpermitted parameters: name error when using Devise

I am trying to follow this as an example: https://github.com/RailsApps/rails-devise/ 我试图以此为例: https//github.com/RailsApps/rails-devise/

I made a project of my own where I try it out and everything is working fine exept for the name part. 我做了一个我自己的项目,在那里我尝试了,一切都工作得很好,因为名称部分。 If I try to make a new user or edit it, rails will throw this Unpermitted parameters: name error. 如果我尝试创建新用户或编辑它,rails将抛出此Unpermitted parameters: name错误。

I have added name as a string into the users table and everything should be fine. 我已将名称作为字符串添加到users表中,一切都应该没问题。 I read that some people suggested adding a specific user_params mathod to allow :name but the example I linked before does not have it and in there it all works. 我读到有些人建议添加一个特定的user_params mathod来允许:name但我之前链接的示例没有它,并且在那里它都可以工作。

Also worth noting maybe that a direct INSERT INTO in pgAdmin will insert a new row with a name without any problems. 另外值得注意的是,pgAdmin中的直接INSERT INTO将插入一个名称没有任何问题的新行。 So it's something with Rails. 所以它与Rails有关。

"Unpermitted parameters" means you're doing mass assignment without marking the passed in parameter as permitted. “未允许的参数”表示您正在进行批量分配,而不会将传入的参数标记为允许。 Have another look at this section of the example app documentation: https://github.com/RailsApps/rails-devise/#adding-a-name-attribute . 再看一下示例应用程序文档的这一部分: https//github.com/RailsApps/rails-devise/#adding-a-name-attribute Make sure the name attribute is listed in config/initializers/devise_permitted_parameters.rb . 确保name / initializers / devise_permitted_pa​​rameters.rb中列出了name属性。

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

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