我使用带有ruby rails 4的货币,我在我用用货币创建的用户表中添加字段,关注的是当我想要更改我的电子邮件时它可以工作但是如果我想更新其他字段没有任何反应所以我不这样做知道什么会忘记。
这里的货币形式或我添加了字段。
%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"
答案 0 :(得分:1)
要update
添加到Devise模型的自定义字段,您必须明确允许它们:
在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