答えがわからない単純なタスク:
トピック、ページ、サブページの 3 つのモデルがあります。
topics has_many pages
pages has_many subpages
pages belongs_to topics
subpages belongs_to pages
URL スラッグに基づいてトピックを探します。
@topic = Topic.find_by_slug(params[:topic])
ここで、トピックに関連するすべてのサブページにアクセスしたいので、実際にはページを「スキップ」したいと考えています。
@subpages = Subpage.where(topic => @topic)
そのクエリはどのように見えますか?
助けてくれてありがとう。