基于Rails的Apache日志分析与成本报告系统搭建
1. 代码文件创建与配置
首先,我们需要创建和配置一系列代码文件,以搭建整个系统。以下是具体步骤:
1. 创建控制器文件 :将以下代码保存为 app/controllers/report_controller.rb 。
class ReportController < ApplicationController
def combined
@rails_pdf_inline = true
@graph_files = {
'Graph of per-sale costs' => get_sale_graph_tempfile,
'Graph of total visitors from each advertiser' => get_visitor_graph_tempfile
}
render :layout => nil
@graph_files.each do |label, filename|
File.unlink filename
end
end
protected
def get_tempfile_name(prefix)
File.join(RAILS_ROOT, "tmp/#{prefix}_#{request.env['REMOTE_ADDR']}_#{Time.now.to_f}_#{rand(10000)}.jpg")
end
def get_
超级会员免费看
订阅专栏 解锁全文
11万+

被折叠的 条评论
为什么被折叠?



