0

I have a two model setup, users and profiles. I am using devise 4.2 for authentication and am filling out the profile via nested attributes, as done here Rails 4.0 with Devise. Nested attributes Unpermited parameters

I would like to make it so that devise will not submit the form without the nested attributes filled out by the user. (making them required attributes) How would I go about doing this?

sakurashinken
  • 2,851
  • 5
  • 23
  • 56

1 Answers1

0

You need to make changes in devise registrations views. Generate views for both models: rails g devise:views users and rails g devise:views profiles.

Open registrations/new.html.erb and add html5 required:true attribute to required fields, ex. for email <%= f.email_field :email, required: true %>

When open your a nested model and be sure validation is existed for necessary fields, ex.: validates :first_name, presence: true.

Alex Kojin
  • 4,588
  • 2
  • 23
  • 25