ActiveRecordã使ã£ã¦ãã¦unionããããã¿ã¼ã³ãã§ããã®ã§ããã£ã¦ã¿ããã¨æã£ãããæãã®å¤ããã£ã¦ãã¾ã£ãã®ã§æ å ±å ±æãããã¨æãã¾ãã ActiveRecordã«unionã¨ããã¡ã½ããããããã¨ãç¥ã£ãç§ã¯ãããã§ã§ããããããªãã®ï¼ã¨æã£ã¦ææ°æã ã¨ä½¿ã£ãã®ã§ããããªããã¨ã©ã¼ãããã¾ããã union = MyGroup.where(user_id: user).reorder(nil).union( MyGroup.limited.where(user_id: user.members).reorder(nil) ) MyGroup.from(MyGroup.arel_table.create_table_alias(union, :my_groups).to_sql)
{{#tags}}- {{label}}
{{/tags}}