diff --git a/app/models/site.rb b/app/models/site.rb index b659c8a..bb85d2a 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -8,9 +8,10 @@ class Site < ApplicationRecord friendly_id :name, use: %i[finders] has_many :roles - has_and_belongs_to_many :usuaries, class_name: 'Usuarie' - has_and_belongs_to_many :invitades, class_name: 'Usuarie', - join_table: 'invitades_sites' + has_many :usuaries, -> { where('roles.rol = ?', 'usuarie') }, + through: :roles + has_many :invitades, -> { where('roles.rol = ?', 'invitade') }, + through: :roles, source: :usuarie # Carga el sitio Jekyll una vez que se inicializa el modelo after_initialize :load_jekyll!