From 1bf3fc012872ec2de0461bd68657d4fdbf85a03f Mon Sep 17 00:00:00 2001 From: f Date: Mon, 8 Jul 2019 14:08:06 -0300 Subject: [PATCH] cambiar las asociaciones de sitios y usuaries a traves de roles --- app/models/site.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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!