)
Size: a a a
)
AI
AI
AI
AI
RU
IN
AI
IN
IN
IN
D
D
D
SE
association = Company.reflect_on_association(:responsible_group)
id = association.foreign_key
для этого я в модели определяю её так
class Company < ApplicationRecord
belongs_to :responsible, class_name: 'User', foreign_key: :responsible_id
has_one :responsible_group, :class_name => 'UserGroup', through: :responsible
...
end
class User < ApplicationRecord
belongs_to :group, class_name: '::UserGroup', foreign_key: :user_group_id
...
end
class UserGroup < ApplicationRecordно он не работает, ругается
has_many :users
end
ActiveRecord::Reflection::ThroughReflection#foreign_key delegated to source_reflection.foreign_key, but source_reflection is nil
IN
D
IN
IN
association = Company.reflect_on_association(:responsible_group)
id = association.foreign_key
для этого я в модели определяю её так
class Company < ApplicationRecord
belongs_to :responsible, class_name: 'User', foreign_key: :responsible_id
has_one :responsible_group, :class_name => 'UserGroup', through: :responsible
...
end
class User < ApplicationRecord
belongs_to :group, class_name: '::UserGroup', foreign_key: :user_group_id
...
end
class UserGroup < ApplicationRecordно он не работает, ругается
has_many :users
end
ActiveRecord::Reflection::ThroughReflection#foreign_key delegated to source_reflection.foreign_key, but source_reflection is nil
SE