stackow1
stackow1

Reputation: 311

how to combine the two systems are the users?

please help solve the problem.

on rails4 i install gem 'devise'. after i install gem 'activeadmin'. in result i have 2 users systems:

create_table "admin_users", force: :cascade do |t|
  t.string   "email",                  default: "", null: false
  t.string   "encrypted_password",     default: "", null: false
  t.string   "reset_password_token"
  t.datetime "reset_password_sent_at"
  t.datetime "remember_created_at"
  t.integer  "sign_in_count",          default: 0,  null: false
  t.datetime "current_sign_in_at"
  t.datetime "last_sign_in_at"
  t.string   "current_sign_in_ip"
  t.string   "last_sign_in_ip"
  t.datetime "created_at"
  t.datetime "updated_at"
end

create_table "users", force: :cascade do |t|
  t.string   "email",                  default: "", null: false
  t.string   "encrypted_password",     default: "", null: false
  t.string   "reset_password_token"
  t.datetime "reset_password_sent_at"
  t.datetime "remember_created_at"
  t.integer  "sign_in_count",          default: 0,  null: false
  t.datetime "current_sign_in_at"
  t.datetime "last_sign_in_at"
  t.string   "current_sign_in_ip"
  t.string   "last_sign_in_ip"
  t.datetime "created_at"
  t.datetime "updated_at"
end

for enter to adminpanel i use admin_users login and password. for enter to private part of site i use users login and password.

but I need you to admin_users have the ability to enter into private part of site.

Upvotes: 0

Views: 37

Answers (2)

Alexander Shlenchack
Alexander Shlenchack

Reputation: 3869

When you install ActiveAdmin you shoul skip user generation:

rails generate active_admin:install --skip-users

Or told AD use another model name:

rails g active_admin:install User

Also you should consider to use single table for User model. If you need separate you users you can:

Add some field for defining your admin user:

add_column :users, :is_admin, :boolean, default: false

Or create roles for users

class User < ActiveRecord::Base
  belongs_to :role
end

class Role < ActiveRecord::Base
  has_many :users
end

Or create STI

class Admin < User
  # other code here
end

Upvotes: 1

Moustafa Sallam
Moustafa Sallam

Reputation: 1132

you should have told activeadmin the name of the user model when you install it i.e rails g active_admin:install User

This would have instruct activeadmin to use the existing model.

For further information please visit activeadmin site

Upvotes: 1

Related Questions