Ruby on rails 在Rails中存储上一年的旧数据?

Ruby on rails 在Rails中存储上一年的旧数据?,ruby-on-rails,activerecord,Ruby On Rails,Activerecord,我正在开发一个有大量数据输入的应用程序。 这是一个类似的活动,它有诸如每平方英尺的价格、开始日期、结束日期等属性。i、 e最长日期约为30天 一旦活动结束,它就结束了,另一个活动就开始了。 现在我很困惑,如何将这些活动存储为报告,以便不定期访问。我的意思是以这样一种方式存储,它将像未来几年的报告一样工作 它有点像会计年度,在会计年度中,上一年度的报告与所有计算一起存储,以便在以后检索时,不应执行所有算法和计算。类似于冻结数据的东西???您可以将活动报告存储在数据库或文件系统中。可在第一次请求存档

我正在开发一个有大量数据输入的应用程序。 这是一个类似的活动,它有诸如每平方英尺的价格、开始日期、结束日期等属性。i、 e最长日期约为30天

一旦活动结束,它就结束了,另一个活动就开始了。 现在我很困惑,如何将这些活动存储为报告,以便不定期访问。我的意思是以这样一种方式存储,它将像未来几年的报告一样工作


它有点像会计年度,在会计年度中,上一年度的报告与所有计算一起存储,以便在以后检索时,不应执行所有算法和计算。类似于冻结数据的东西???

您可以将活动报告存储在数据库或文件系统中。可在第一次请求存档活动时生成报告

class Campaign < ActiveRecord::Base   
  # Campaign model has an attribute called report_file
  def report_file
    return nil unless expired?
    attributes['report_file'] ||= generate_report_file
  end

  def generate_report_file
    return nil if attributes['report_file']
    # Generate the report using Prawn PDF OR wickedPDF etc.
    # Update report_file attribute with the report file location
    # Return the file location
  end
end

class CampaignsController < ApplicationController
  before_filter :check_expiry, :only => :show
  def report
    if @campaign.report_file
      send_file(@campaign.report_file)
    else
      # handle error
    end
  end
  def show
  end
  def check_expiry
    @campaign = Campaign.find(params[:id])
    if @campaign.expired?
      render :report
    end
  end
end
class活动:show
def报告
如果@campaign.report\u文件
发送文件(@campaign.report\u文件)
其他的
#处理错误
终止
终止
def秀
终止
def检查到期
@活动=活动.查找(参数[:id])
如果@campaign.expired?
呈现:报告
终止
终止
终止

感谢您的精彩解释。我试一下再回来。