Recently, the company wants to upgrade redmine to version 2.3.0. The setup process is still smooth due to the previous setup. However, after the setup, the problem is found. After logging on to the background, click "my account" and "manage"-"" set "to report an error. The page prompts internal error. The title of the page is redmine 500 error. The error message in log is as follows.
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'
Someone said on the Internet that this problem can be solved after Ruby is upgraded from 1.8.7 to 1.9.3. However, redmine2.3.0 supports Ruby 1.8.7, in addition, after I installed Ruby 1.9.3, there were a bunch of problems in the environment (because Ruby already has two sets on this machine, one of which does not know who built it, the old version is unavailable, so I am not compatible with various conflicts after the installation), so I gave up this solution. If you are interested, try it.
Later, I found another solution and finally solved my problem, as shown below for your reference.
#cd /var/www/redmine#vi app/helpers/application_helper.rb
Find the following content and delete or add it accordingly.
Def lang_options_for_select (blank = true) (blank? [["(Auto)", ""]: []) + languages_options // Delete this row (blank? [["(Auto)", ""]: []) + // Add the valid_languages.collect {| Lang | [LL (Lang. to_s,: general_lang_name), Lang. to_s]}. sort {| X, Y | X. last <=> Y. last} // Add this row end
#vi lib/redmine/i18n.rb
Find the following content and delete all.
# 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
Find the following content and delete all.
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
Restart and try again. All the problems will be solved, bingo !!!