Ruby on rails Rails 5上设备的自定义字段
我已经安装了Desive gem,并将Ruby on rails Rails 5上设备的自定义字段,ruby-on-rails,devise,ruby-on-rails-5,Ruby On Rails,Devise,Ruby On Rails 5,我已经安装了Desive gem,并将全名和位置的自定义字段作为字符串添加到数据库中 我将编辑和新建表单页面更新为: <%= f.input :fullname, required: true %> <%= f.input :location %> 但它不会保存或更新此字段 我看不到任何控制器 我错过了什么?我看了几十本教程,但都没看懂 我使用的是Rails 5.1.3和Ruby 2.4.0p0。您可以在筛选之前使用配置允许的\u参数以“惰性方式”完成此操作 在应
全名
和位置
的自定义字段作为字符串添加到数据库中
我将编辑
和新建
表单页面更新为:
<%= f.input :fullname, required: true %>
<%= f.input :location %>
但它不会保存或更新此字段
我看不到任何控制器
我错过了什么?我看了几十本教程,但都没看懂
我使用的是Rails 5.1.3和Ruby 2.4.0p0。您可以在筛选之前使用配置允许的\u参数以“惰性方式”完成此操作
在应用程序控制器中,添加受保护的方法,指定要在设计\u参数\u消毒剂中允许的密钥。然后,如果所使用的控制器是Desive注册的控制器,则添加指向此方法的before_操作回调
在您的情况下,可能类似于:
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
permit_attrs(%i[fullname location])
end
def permit_attrs(attrs)
%i[sign_up account_update].each do |action|
devise_parameter_sanitizer.permit(action, keys: attrs)
end
end
end
class ApplicationController