我有2個模型報告和報告belongs_to人與報告has_many報告。 我想在人民電網 '看報告' 的鏈接,以顯示該特定人的報告如何顯示特定人員的報告?
{的link_to 「報告」,admin_reports_path(:爲person_id => person.id,:日期=> 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
末
u能張貼CONTROLER代碼 – Amar
我編輯我的問題 –