나는 최근에 양식 제출시 수정 된 필드 목록을 보여주기 위해 노력 해왔다. 유일한 문제는 내 양식 (간단한 양식 사용)은 일부가있을 때 오류를 표시하지 않으며 양식을 제출할 수 없다는 것입니다. 여기 레일즈 3의 간단한 폼 문제
는 내 코드를 단순화 것 :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
사람에게 생각을 했습니까?
미리 감사드립니다.
또한보기 코드도 게시해야합니다. –
알겠습니다. 게시판은 – Cydonia7
입니다. 어디에서 'assign_attributes'를 얻었습니까? (레일 3.1과 관련하여'update_attributes'는 이전 버전에서 더 일반적으로 사용됩니다)? 마법사에서 일하러 가고 있습니까? –