0

Rails Composer を使用して、Rails プロジェクトのスターター アプリを作成しました。役割の作成と管理にdeviseを使用しています

ユーザーには次の役割があります: 採用担当者、応募者 ユーザーは [採用担当者、応募者] のいずれかまたは両方を実行できます

User モデルを見ましたが、外部キーの role_id 列がありません。その列を自分で追加しましたが、次の問題に直面しています

1]アプリは、サインアップしたすべてのユーザーにrole_id = 1のみを割り当てます

2] 採用担当者と応募者の両方であるユーザーの場合、[ユーザー] 列に [1 と 2] の異なる ID を持つ 2 つの役割があるでしょうか。このモデルをどのように処理する必要がありますか?

これは私のユーザーモデルです:

class User < ActiveRecord::Base
  rolify
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :role_ids, :as => :admin
  attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :user_id, :role_ids
  validates_presence_of :email

  has_many :applications
  has_many :jobs          
end
4

0 に答える 0