If you use Devise , you can easily achieve this in a few lines:
1- Add the attribute adminto the development table:
and. You can add it with the migration $ rails generate migration add_admin_to_users admin:boolean. Now your migration will look like this:
class AddAdminToUsers < ActiveRecord::Migration
def change
add_column :users, :admin, :boolean, :default => false
end
end
b. You can also add it to the device table before transferringt.boolean :admin, null: false, default: false
2- In your opinion, you can do this:
<%= link_to "Users", users_path if current_user.admin? %>
After adding a table admin?to Devise, it becomes an attribute similar to the emailothers. And it ends with a question mark ?, because it's a Boolean type.
source
share