-1

I'm new in rails and want to create an app that has 3 different types of users: normal user, partners, admin

what i want to do is that in the navbar you could sign up like partner or normal user and later if you are a normal user could change to partner and i want to know the best way to make it.

Thanks.

1 Answers1

0

The easiest way would be to add a user_type column to the User model.

rails g migration add_user_type_to_users user_type:string

The user_type field is populated with a string, eg: 'normal' or 'partner', then elsewhere in your code you test for this.

if current_user.user_type == 'partner'
  # do something
else
  # error message
end

You could also use a more complex solution like Rolify https://github.com/RolifyCommunity/rolify

port5432
  • 5,889
  • 10
  • 60
  • 97
  • PS - I don't know why your post was voted down, but don't be discouraged: StackOverflow is a great resources for programming help. – port5432 Jan 25 '17 at 07:12
  • thanks, i also use rolify and i've created 2 roles: normal and partners, and setting normal role by default role, now what i want to do is that the normal user could upgrade to partner by completing a form giving more information that is important to be a partner and with a buttom upgrade their role. if you could help me it will be very amazing. thank you for the last answer. – Carlos Chiw Jan 25 '17 at 22:54