私はレポートの2つのモデルReportとPersonを持っています。People's Grid に「レポートを見る」リンクを作成して、その特定の人物のレポートを表示したい
{link_to "Reports", admin_reports_path(:person_id => person.id, :date => Date.today)}
ただし、このリンクをクリックすると、今日だけでなく、すべての人からのすべてのレポートが表示されます。私は何を間違っていますか?ありがとう!
レポート コントローラー:
デフォルト create_daily
person_id = @person.id
reports = params[:reports] || []
date = Date.today
reports.each do |index, attributes|
project = Project.find_by_short_name(attributes[:short_name])
project_id = project.id if project
date = Date.parse(attributes[:date])
report = Report.where(:person_id => person_id, :project_id => project_id, :date => date).first_or_initialize
report.person_id = person_id
report.project_id = project_id
report.date = date unless report.date # Do not overwrite if already existing
report.day_off = attributes[:day_off] == 'true'
report.body = attributes[:body].to_s.strip
report.time_estimate = attributes[:time_estimate].to_s.strip
report.save
end
respond_to do |format|
format.html { redirect_to reports_url }
format.json { render :json => { :reports => Report.by_reporter(current_user).for_date(date) } }
end
終わり