我最近一直在尝试显示在提交表单时成功修改的字段列表。唯一的问题是我的表单(我使用简单表单)在有一些错误并且无法提交表单时不显示错误。
这是我的简化代码:
def update
@wizard.assign_attributes(params[:wizard])
# Get changed attributes
if @wizard.save
# Set the success flash with fields modified
redirect_to @wizard
else
@title = "Edition du profil"
render 'edit'
end
end
风景 :
<%= simple_form_for @wizard do |f| %>
<%= f.input :email %>
<%= f.input :story %>
<%= f.submit "Modifier", :class => "btn success small" %>
<% end %>
该模型 :
class Wizard < ActiveRecord::Base
has_secure_password
attr_accessible :email, :story, :password, :password_confirmation, :password_digest
serialize :ranks, Array
validates_presence_of :email, :first_name, :last_name, :gender, :story
validates_presence_of :password, :password_confirmation, :unless => Proc.new { |w| w.password_digest.present? }
# Other validations here
has_one :subject, :foreign_key => "teacher_id"
ROLES = %w[teacher]
scope :with_role, lambda { |role| {:conditions => "roles_bitmask & #{2**ROLES.index(role.to_s)} > 0"} }
# Other functions here
end
有人有想法吗?
先感谢您 !