AnApprentice
AnApprentice

Reputation: 111030

How to enable a user to enter a FullName to create a New Account

I'm using Rails Devise. My user model has (id, first_name, last_name).

My sign up form currently includes the two fields for first_name and last_name.

I would like my signup form to have just one field, full_name

And for full_name to be a virtual attr which validates to ensure the fullname contains a first and last name (two strings)...

How can I set this up in my user model to have a full_name on user create, be validated and then set first_name and last_name.

Upvotes: 0

Views: 90

Answers (1)

Igor Drozdov
Igor Drozdov

Reputation: 15045

You may need to configure views for registerable module

According to documentation you can generate views for a particular module and receive them all inside app/views/devise/registrations folder

rails generate devise:views -v registrations

Then just go and extend app/views/devise/registrations/new.html.erb by adding a required full-name fields

Upvotes: 1

Related Questions