Reputation: 1217
I am new to Rails and have used Devise gem for User authentication etc. On my app I would also like to track additional User attributes such as First Name, Last Name, etc..
What is the best way to be able to manage the additional User information. Do I add the columns required to the User model created by the Devise gem OR do I create a brand new model/table to hold this information with the appropriate associations between the two models?
thanking in advance.
regards
Upvotes: 0
Views: 103
Reputation: 919
if you just have a application without a user profile it would be better to add first name and last name to user rails g migration add_first_name_and_last_name_to_users first_name:string last_name:string
and in your application controller add this
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation, :first_name, :last_name)}
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :current_password, :password , :password_confirmation, :first_name, :last_name)}
end
however if you have a app with profile it can be better to create a Profile model that have first name and last name and others parameters such as user summary etc
Upvotes: 1