저는 레일을 처음 사용합니다. 사용자 역할 추가에 rolify gem을 사용하고 있습니다. 레일 콘솔에서 역할을 추가하려고 할 때이 문제가 발생합니다. 이 문제에 직면 한 사람이 있습니까?ActiveRecord :: RecordInvalid : 유효성 검사에 실패했습니다. 리소스 유형이 lis에 포함되어 있지 않습니다.
u = User.first
u.add_role(:admin).save!
내가로부터 rolify 설치 설명서를 따랐다
ActiveRecord::RecordInvalid: Validation failed: Resource type is not included in the list.
Rolify 마이그레이션 파일 ============
class RolifyCreateRoles < ActiveRecord::Migration
def change
create_table(:roles) do |t|
t.string :name
t.references :resource, :polymorphic => true
t.timestamps
end
create_table(:users_roles, :id => false) do |t|
t.references :user
t.references :role
end
add_index(:roles, :name)
add_index(:roles, [ :name, :resource_type, :resource_id ])
add_index(:users_roles, [ :user_id, :role_id ])
end
end`
오류 목록 === 여기에 == https://github.com/RolifyCommunity/rolify
언제든지 레일스 콘솔을 시작한 후 rake db : migration을 실행 했습니까? – Sanjiv
감사합니다. 하지만 난 아니야 – Sazzad
여기에서 모델을 지난 수 있습니까? – Sanjiv