I have a users model in my rails application. It has a name attribute only along with email & password added to it for login via Devise. I want to create a model Profile for users. How shall I create it. Either by adding profile attributes to existing User model or by creating a model Profile and adding a belongs_to association to it.
Adding more attributes to your user model will make your user object a bit heavy and is not the best idea given that you'll be calling that object quite often. For instance, to verify a user, you don't need to load the profile attributes like location or date of birth, which the current_user helper would. So, its better to extract profile attributes in a separate model and adopt either of gabreilhilal's approaches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With