最近公司要把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 16msActionView::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!!!