基于Rails的Apache日志分析与成本报告系统搭建
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
超级会员免费看
订阅专栏 解锁全文
11万+

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



