[英]Unable to save data add to the model created with Devise (name model : user )
I use currency with ruby rails 4, I add fields in my user table I created with currency and the concern is when I want to change my email it works but if I want to update the other fields nothing happens so I do not know what 'would forget. 我将货币与ruby rails 4一起使用,在使用货币创建的用户表中添加字段,而关注的是当我想更改电子邮件时可以使用,但是如果我想更新其他字段,则什么也没有发生,所以我不知道什么是“会忘记的。
Here the form of currency or I add the fields. 在这里以货币形式或我添加字段。
%h2
Edit #{resource_name.to_s.humanize}
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
= devise_error_messages!
%div
= f.label :email
%br
= f.email_field :email, :value =>"#{current_user.email}"
%div
= f.label 'Mot de passe'
%i (Pour valider votre profil)
%br
= f.password_field :current_password
%div
= f.label 'Nom'
%br
= f.text_field :username, :value=>"#{current_user.username}"
%div
= f.label 'Prenom'
%br
= f.text_field :firstname, :value=>"#{current_user.firstname}"
%div
= f.label 'Adresse'
%br
= f.text_field :adress, :value=>"#{current_user.adress}"
%div
= f.label 'Code postal'
%br
= f.text_field :cp, :value=>"#{current_user.cp}"
%div
= f.label 'Ville'
%br
= f.text_field :city, :value=>"#{current_user.city}"
%div= f.submit "Mise à jour du profil"
To update
the custom fields that you added to Devise model, you will have to permit them explicitly: 要
update
添加到Devise模型中的自定义字段,必须明确允许它们:
Add the following code in your ApplicationController
在您的
ApplicationController
添加以下代码
class ApplicationController < ActionController::Base
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
## Permit the custom fields below which you would like to update, I have shown a few examples
devise_parameter_sanitizer.for(:account_update) << :currency << :username << :firstname
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.