0
私はRails 5を使っていますが、私は他のクエリとhas_and_belongs_to_many関係をしたいと考えています。 2つのクエリをマージするのではなく、同じではありません。実際に私はこのきれいな方法をしたい。Rails has_and_belongs_to_many他のクエリとの関連
私はそれをきれいにすることができますか?
@branch.course_contents.active + CourseContent.show_all_branches
このSQL出力をレールで書きたいと思います。そのsqlコマンドは私のためにうまく動作します。
select *,
(select branch_id
from branches_course_contents
where course_content_id=course_contents.id and branch_id=2) as Sube
from course_contents
where
(select branch_id
from branches_course_contents
where course_content_id=course_contents.id and branch_id=2)=2
or show_all_branches=true)
and content_type=0
が、その私には働いていません。 –
「働いていない」とはどういう意味ですか?コンソールからクエリを表示できますか? – archana
質問の説明が更新されました。そのsqlコマンドは正常に動作します。私はレールでそれを書いています。 –