私が持っている:コントローラで次にインスタンス変数への負荷関連付けを熱望する方法は?モデルで
class CalendarItem < Resource
belongs_to :schedule
has_many :people
has_many :documents
acts_as_list scope: :schedule, column: :visual_position
validates :schedule, :title, presence: true
end
:
私が反応し、レールとreact_componentをレンダリングしています(しかし、それはすべての違いを作る必要があります)を考慮してclass ScheduleController < ApplicationController
def show
@calendar_items = CalendarItem.where(schedule: @schedule).includes(:people, :documents)
end
...
end
:
= react_component('CalendarItemsList', calendar_items: @calendar_items)
ただし、関連するデータはビュー(react_component)に渡されず、メインモデルのみが渡されます。
私はこれまでに、反応していないフロントエンドでこれを経験しましたが、どちらもうまくいきませんでした。何が間違っていますか?
空の配列nilを渡すか、エラーをスローしますか? –
私は@caledar_itemsを使うことができますが、人々と文書の関連付けは含まれていません。おかげで – Aurimas
ああ、それは簡単にする必要があります。 'CalendarItem.includes().where()'を試してください。あなたは注文を後方に持っています。 –