在具有搜索过滤器的页面上使用Prawn

时间:2018-04-05 04:52:24

标签: ruby-on-rails prawn

我正在尝试使用月度声明的可打印pdf。声明页面包含月份和年份过滤器。当我渲染PDF时,它只会在输入搜索参数之前渲染页面。

def show

  respond_to do |format|

    if params[:month_select]
      @month = params[:month_select]
      @year = params[:year_select]
      search_date(@user)
      @date = Date.new(@year.first.to_i, @month.first.to_i)
      total_deductions

    else
      @date = Date.today
      @trips

  end

  format.html
  format.pdf do
    pdf = UserPdf.new(@user, @date)
    send_data pdf.render, filename: "#{@user} #{@month} #{@year},
                          type: "application/pdf",
                          disposition: "inline"
  end

 end

end

不确定我应该做什么。

def search_date(user)
  @trips = user.trips.month_year(params[:month_select],params[:year_select])
  @advances = user.advances.month_year(params[:month_select],params[:year_select])
  @prorates = user.prorates.month_year(params[:month_select],params[:year_select])
  @icbcs = user.icbcs.month_year(params[:month_select],params[:year_select])
  @dentals = user.dentals.month_year(params[:month_select],params[:year_select])
  @others = user.others.month_year(params[:month_select],params[:year_select])
  @admin_expenses = user.admin_expenses.month_year(params[:month_select],params[:year_select])
  @ifta_refunds = user.ifta_refunds.month_year(params[:month_select],params[:year_select])
  @fuel_caps = user.fuel_caps.month_year(params[:month_select],params[:year_select])
  @other_deposits = user.other_deposits.month_year(params[:month_select],params[:year_select])
end

0 个答案:

没有答案