저는 ruby 1.9.2-p180, rail 3.0.7을 사용하고 있습니다. 사용자가 이용 약관에 동의해야하므로 validates_acceptance_of를 사용했습니다. 우리는 이에 대한 칼럼이 없지만 "데이터베이스 열이 존재하지 않으면 terms_of_service 속성은 완전히 가상입니다."라고 알았습니다. from http://ar.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000082validates_acceptance_of는 여전히 레코드를 저장합니다
어쨌든, 저는 이것을 수동으로 테스트하여 연기를 다시 확인했습니다. 로그에서 레코드가 여전히 DB에 삽입 된 것을 볼 수 있습니다. 그 이유는 폼을 제출할 때 오류가있는 양식으로 다시 리다이렉트 되었기 때문입니다. "조건에 동의해야합니다" 이전)
내가 여기서 뭔가 잘못하고 있니?
_form.haml :
def create
user_params = params[:operator][:user]
user_params.merge!(:login => user_params[:email])
@password = params[:operator][:user][:password]
Operator.transaction do # don't save User if operator is invalid
@operator = Operator.create(params[:operator])
end
respond_to do |format|
unless @operator.new_record?
UserMailer.operator_confirmation_email(@operator, @password).deliver
UserMailer.operator_registration_admin_notification_email(@operator).deliver
UserSession.create(@operator.user)
format.html {redirect_to new_operator_aircraft_path}
else
format.html { render :action => "new" }
end
end
end
와 모델 :
%label.checkbox-label{:for => "operator_terms_and_conditions"}
= f.check_box :terms_and_conditions
I agree to
= link_to "Terms and Conditions", operator_terms_path, :target => "_blank"
operators_controller
validates_acceptance_of :terms_and_conditions