Am building a rails app where i want to have two types of users i.e sellers and buyers. Users can choose at the time of signup weather they want to signup as seller or buyer.
I created users using devise then
added enum role: [:seller, :buyer]
in user.rb
then created a migration to add roles to user
rails g migration add_role_to_users
my migration looks like this:
class AddRoleToUsers < ActiveRecord::Migration
def change
add_column :users, :role, :integer
end
end
I am using simple form, in my users registration form
i added
<%= f.select :role, User.roles %>
On the index page i am trying to do this:
<% if current_user.seller? %>
<%= link_to 'New Post', new_post_path %>
<% else %>
hello
<% end %>
but somehow roles of my users is returning as nil, i have checked the console also and even there the roles of my user return as nil, can someone please help me and tell me what am doing wrong. Thanking you