I have a has_and_belongs_to_many
association between keywords
and groups
and then a groups
belongs_to
member
association between group and devise.
class Keyword < ActiveRecord::Base
has_and_belongs_to_many :groups
delegate :member, to: :groups
validate :keywords_within_limit, on: :create
def keywords_within_limit
if self.member.keywords(:reload).count >= self.member.keyword_limit
errors.add(:keyword, "exceeded limit")
end
end
end
Im trying access my members methods using delegate
but I am getting the error NoMethodError - undefined method member for #<ActiveRecord::Associations::CollectionProxy []>:
Why can't I access my members methods using delegate
?
Aucun commentaire:
Enregistrer un commentaire