Skip to content

uninitialized constant Role::Resource when using paper_trail #334

@olegantonyan

Description

@olegantonyan

Hi! I have a problem with rolify+paper_trail. My role model:

class Role < ActiveRecord::Base
  has_paper_trail
  scopify
  has_and_belongs_to_many :user_company_memberships, :join_table => :user_company_memberships_roles
  belongs_to :resource, :polymorphic => true

  validates :resource_type, :inclusion => { :in => Rolify.resource_types }, :allow_nil => true
  validates :name, presence: true, uniqueness: true, length: {:in => 2..30}
end

Trying to create a role:

Role.create(name: 'admin')
NameError: uninitialized constant Role::Resource
from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.1/lib/active_record/inheritance.rb:158:in `compute_type'

But without has_paper_trail it works just fine.
Rails 4.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions