I have models with relationship like this
class User < ActiveRecord::Base
has_many :identities
has_many :activities
end
class Identity < ActiveRecord::Base
belongs_to :user
has_many :manifests
has_many :activities, through: :manifests
end
class Activity < ActiveRecord::Base
belongs_to :user
has_one :link
has_many :manifests
has_many :identities, through: :manifests
end
class Manifest < ActiveRecord::Base
belongs_to :activity
belongs_to :identity
end
class Link < ActiveRecord::Base
belongs_to :activity
end
But when I try to call
user.activities
it raise an error
ActiveRecord::AssociationNotFoundError: Association named 'user' was not found on Link; perhaps you misspelled it?
It got me confused as I don't put user relationship on Link model. Can someone help me?
You could try:
Why? In this case we should make complied join tables
users
,activities
andlinks
.