프로필이 has_one 인 사용자 모델이 있습니다.Devise - 가입시 HAS_ONE 관련 모델에 데이터 삽입
프로필은 모든 사용자 물건 (이름, 전화 번호, 주소, 주 등)이 저장되는 장소입니다.
가입하는 동안 사용자가 해당 입력란을 채우도록해야합니다.
중첩 된 필드를 시도했지만 실제로 작동하지 않으며 그 이유를 실제로 이해하지 못합니다.
비슷한 코드 예제가있는 사람이 있습니까? 인터넷에서 아무것도 찾을 수 없습니다.
Candidate has_one :profile
Profile belongs_to :user
등록 양식 :
= simple_form_for(:candidate,
as: Candidate,
url: candidate_registration_path) do |f|
= f.simple_fields_for :profile do |profile|
= profile.input :first_name
= profile.input :last_name
= f.input :email
= f.input :password
= f.input :password_confirmation
= f.submit 'Start Building', class: 'btn btn-primary'
이 제외 컨트롤러 아무 짓도 안 했어요 :
def configure_devise_params
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:email, :password, :password_confirmation,
profile_attributes: [:first_name, :last_name])
end
end
코드 샘플이 유용 할 것입니다. – Nikola