-1
Rails4에서 확인 유효성 검사를 시도하고 있지만 올바르게 작동하지 않습니다.레일 유효성 검사 - 확인이 올바르지 않음
enter code here
#model user.rb
class User < ActiveRecord::Base
validates :email, confirmation: true
validates :email_confirmation, presence: true
end
#view
<div class="field">
<%= f.label :email_confirmation %><br>
<%= f.text_field :email_confirmation %>
</div>
#controller
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
여기서'email' 필드는 어디에 있습니까? 여기서'email_confirmation' 만 볼 수 있습니다 ... 그리고 존재 확인은 "can not be blank"메시지를줍니다. –
<%= f.text_field :email %>