我正在使用redmine Request-URI太长 请求的网址长度超出了此服务器的容量限制。每当我尝试在时间表插件中选择csv以导出时间表报告时。 我该如何解决这个请告诉我
答案 0 :(得分:1)
问题在于方法。您正在尝试在URL中检索太多参数,而Apache(或任何其他此类参数)默认情况下限制为2000个字符。在我的情况下,我没有访问Apache服务器,因此更改.conf文件不是一个选项。
查看存储库的分支,我发现有人已经解决了这个问题。 Here is a link to SashaH's pull request。 这个拉取请求是相当新的,所以它尚未提交。
只需按照指示更改代码,插件应该可以正常工作:
应用/助手/ timesheet_helper.rb 强>
:timesheet => timesheet.to_param)
end
- def link_to_csv_export(timesheet)
- link_to('CSV',
- {
- :controller => 'timesheet',
- :action => 'report',
- :format => 'csv',
- :timesheet => timesheet.to_param
- },
- :method => 'post',
- :class => 'icon icon-timesheet')
+ def form_for_csv_export(timesheet)
+ params_like_decode_url = CGI.unescape({:timesheet => timesheet.to_param}.to_query)
+ inputs = ""
+ form = form_tag :controller => 'timesheet', :action => 'report', :format => 'csv' do
+ params_like_decode_url.split("&").each do |param|
+ param_arr = param.split("=")
+ inputs << hidden_field_tag(param_arr.first, param_arr.last, :id => "")
+ end
+ inputs << submit_tag("CSV")
+ inputs.html_safe
+ end
+ form.html_safe
end
def toggle_arrows(element, js_function)
app / models / timesheet.rb
def to_csv
out = "";
+
+ handle_time_entries = {}
+ time_entries.each do |k,v|
+ if k.is_a? String
+ handle_time_entries[k] = v
+ next;
+ end
+ handle_time_entries[k.name] = v
+ end
+
+ time_entries = handle_time_entries
FCSV.generate(out, :encoding => 'u', :force_quotes => true) do |csv|
csv << csv_header
@@ -314,7 +325,7 @@ def time_entries_for_user(user, options={})
return TimeEntry.includes(self.includes).
where(self.conditions([user], extra_conditions)).
- order('spent_on ASC')
+ order('spent_on ASC').references(self.includes)
end
def fetch_time_entries_by_project
应用/视图/时间表/ report.html.erb 强>
<div class="contextual">
- <%= link_to_csv_export(@timesheet) %>
+ <%= form_for_csv_export(@timesheet) %>
<%= permalink_to_timesheet(@timesheet) %>
</div>
<强> init.rb 强>
require 'redmine'
## Taken from lib/redmine.rb
-#if RUBY_VERSION < '1.9'
-# require 'faster_csv'
-#else
-# require 'csv'
-# FCSV = CSV
-#end
+if RUBY_VERSION < '1.9'
+ require 'faster_csv'
+else
+ require 'csv'
+ FCSV = CSV
+end
if Rails::VERSION::MAJOR < 3
require 'dispatcher'