delegate
とを含む次の無限ループがわかりませんalias
class Company
field :name
end
class Employee < Professional
include CompanyMember
end
class Professional
include UserProfile
end
module CompanyMember
belongs_to :company
delegate :name, to: :company, prefix: true
alias :organization_name :company_name
end
module UserProfile
def to_s
out = "#{name} "
out += "(#{organization_name})" if respond_to?(:organization_name)
end
def inspect
to_s + super
end
end
行方不明の会社がEmployee
あり、次の無限ループがあります
app/models/concerns/user_profile.rb:94:in `inspect'
app/models/concerns/company_member.rb:8:in `rescue in company_name'
app/models/concerns/company_member.rb:8:in `company_name'
app/models/concerns/user_profile.rb:89:in `to_s'
app/models/concerns/user_profile.rb:94:in `inspect'
app/models/concerns/company_member.rb:8:in `rescue in company_name'
app/models/concerns/company_member.rb:8:in `company_name'
app/models/concerns/user_profile.rb:89:in `to_s'