我有一个渲染良好的报表对象,但是我有一个要传递到报 TableView 的 reportapproval 对象,以便我可以在报 TableView 中运行计算。每个用户有一个报告,每个报告有多个报告批准。如何调用特定的报告批准并将该实例发送到报告 Controller 或 View 。这是我的报告 Controller 。
class Users::ReportsController < ApplicationController
def show
@report = Report.find(params[:id])
authorize @report
end
end
我试图通过
@reportapproval = Reportapprovals.where(user_id: @report.user_id).first
在 show 方法中,但 ReportController 无法识别 Reportapproval。
如何将实例传递给 View ?
最佳答案
我认为你可以这样做
@reportapproval = @report.reportapprovals.first
关于ruby-on-rails - 将对象的实例调用到另一个 Controller 轨中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32508046/