title: how to associate roles from a dropdown box to a user, using rolify
body: <p>I have been trying to get rolify gem to work FOREVER. I have cancancan and devise as well, i basically have a signup page with email, password, password_confirmation, and a dropdown box selecting role. and when i click sign up it gives me an error to the segment of code creating the DDbox. Can anyone help me get this working ? my ability.rb is this</p>
  
  <p>`class Ability
    include CanCan::Ability</p>
  
  <p>def initialize(user)
      user ||=User.new
        if user.has_role? :admin
           can :manage, :all
        elsif user.has_role? :regularUser
           can :read, Menu
        elsif user.has_role? :institution
          can :read, Menu
        elsif user.has_role? :franchiseOwner
          can :read, Menu<br>
        end</p>
  
  <pre><code># Define abilities for the passed in user here. For example:
  #
  #   user ||= User.new # guest user (not logged in)
  #   if user.admin?
  #     can :manage, :all
  #   else
  #     can :read, :all
  #   end
  #
  # The first argument to `can` is the action you are giving the user
  # permission to do.
  # If you pass :manage it will apply to every action. Other common actions
  # here are :read, :create, :update and :destroy.
  #
  # The second argument is the resource the user can perform the action on.
  # If you pass :all it will apply to every resource. Otherwise pass a Ruby
  # class of the resource.
  #
  # The third argument is an optional hash of conditions to further filter the
  # objects.
  # For example, here the user can only update published articles.
  #
  #   can :update, Article, :published =&gt; true
  #
  # See the wiki for details:
  # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
  end
   end `
  </code></pre>
  
  <p>and this the the dropdown box code snippet from my view/devise/registation/new.html.erb..<br>
        <code>&lt;%= user_form.select :role,        options_from_collection_for_select(Role.all,"Institution","Regular User", "Franchise Owner")%&gt;</code></p>
  
  <p>this is my User.rb model</p>
  
  <pre><code>`class User &lt; ActiveRecord::Base
   rolify :before_add =&gt; :before_add_method
  
   # Include default devise modules. Others available are:
   # :confirmable, :lockable, :timeoutable and :omniauthable
   devise :database_authenticatable, :registerable,
       :recoverable, :rememberable, :trackable, :validatable
  
   def before_add_method(role)
  
   end
   end`
  </code></pre>
  
  <p>and my users_controller</p>
  
  <pre><code>`class UserController &lt; ApplicationController
   def index
    @users = User.all
   end
  
   def new
     @user = User.new
   end
  
  
   # POST /userss
   # POST /users.json
   def create
   @user = User.new(user_params)
   @user.add_role params[:user][:role]
   end
  
   private
   def user_params
  params.require(:user).permit(:email, :password, :password_confirmation,    :role)
  end
  end`
  </code></pre>