最近公司要把redmine升级,要求版本为2.3.0,因为之前搭过,所以搭建过程还算顺利,但是搭完之后发现了问题,后台登陆之后,点击“我的帐户”,及“管理”-》“设置”据报错。页面提示Internal error,页面的title是redmine 500 error。log里面的报错信息如下。
Processing by MyController#account as HTML
Current user: test (id=3)
Rendered my/account.html.erb within layouts/base (8.6ms)
Completed 500 Internal Server Error in 16ms
ActionView::Template::Error (wrong number of arguments (2 for 1)):
16: <p><%= f.text_field :firstname, :required => true %></p>
17: <p><%= f.text_field :lastname, :required => true %></p>
18: <p><%= f.text_field :mail, :required => true %></p>
19: <p><%= f.select :language, lang_options_for_select %></p>
20: <% if Setting.openid? %>
21: <p><%= f.text_field :identity_url %></p>
22: <% end %>
lib/redmine/i18n.rb:95:in `languages_options'
app/helpers/application_helper.rb:974:in `lang_options_for_select'
app/views/my/account.html.erb:19:in `_app_views_my_account_html_erb___278591561__616683068'
app/helpers/application_helper.rb:989:in `labelled_form_for'
app/views/my/account.html.erb:9:in `_app_views_my_account_html_erb___278591561__616683068'
网上有人说,把ruby从1.8.7升级到1.9.3之后此问题就可以解决了。但是通过官网上面的版本对照,redmine2.3.0是可以使用ruby 1.8.7的,再加上我在安装了ruby 1.9.3之后环境出了一堆问题(因为本身此机器上ruby已经搭了两套了,其中有一套不知道是谁搭的,反正是老版本,不可用了,所以我这次安装之后各种冲突不兼容),所以放弃了此解决方案,大家有兴趣的可以试试。
后来查找到另外一种解决方案,终于解决了我的问题,如下,供大家参考。
#cd /var/www/redmine
#vi app/helpers/application_helper.rb
找到以下内容,进行相应的删除或添加。
def lang_options_for_select(blank=true)
(blank ? [["(auto)", ""]] : []) + languages_options //删除此行
(blank ? [["(auto)", ""]] : []) + //添加此行
valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last } //添加此行
end
#vi lib/redmine/i18n.rb
找到以下内容,并全部删除。
# Returns an array of languages names and code sorted by names, example:
# [["Deutsch", "de"], ["English", "en"] ...]
#
# The result is cached to prevent from loading all translations files.
def languages_options
ActionController::Base.cache_store.fetch "i18n/languages_options" do
valid_languages.map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.sort {|x,y| x.first <=> y.first }
end
end
# vi test/unit/lib/redmine/i18n_test.rb
找到以下内容,并全部删除。
def test_languages_options
options = languages_options
assert options.is_a?(Array)
assert_equal valid_languages.size, options.size
assert_nil options.detect {|option| !option.is_a?(Array)}
assert_nil options.detect {|option| option.size != 2}
assert_nil options.detect {|option| !option.first.is_a?(String) || !option.last.is_a?(String)}
assert_include ["English", "en"], options
end
再重启试试看,问题就全部解决啦,BINGO!!!