diff --git a/CHANGELOG.md b/CHANGELOG.md index 51b26a46..8760ff3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * [#202] Fixed an issue with adding to the lexeme form when assigned to multiple dictionaries * [#169] Short lists now only show the most acceptable headwords * [#234] Fixed an issue with listing additional loci for potential constructions +* [#180] Fixed an issue that forced a restart to use newly-added languages ## Since 0.4.1 * [#89] Lexeme form now arranges etymology horizontally instead of by nesting diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index bc2dbe15..54e01c37 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -47,6 +47,8 @@ def create respond_to do |format| if @language.save + update_accessors + flash[:notice] = t('languages.new.success') format.html { redirect_to(@language) } format.xml { render :xml => @language, :status => :created, :location => @language } @@ -64,6 +66,8 @@ def update respond_to do |format| if @language.update_attributes(params[:language]) + update_accessors + flash[:notice] = t('languages.edit.success') format.html { redirect_to(@language) } format.xml { head :ok } @@ -94,4 +98,13 @@ def matching format.js { render :partial => "autocomplete" } end end + + private + + # Update accessors for models that have accessors defined + def update_accessors + ActiveRecord::Base.descendants.each do |c| + c.globalize_accessors(locales: Language.defined_language_codes) if c.respond_to?(:globalize_locales) + end + end end diff --git a/app/models/language.rb b/app/models/language.rb index dff2209b..a1d1bca0 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -109,7 +109,7 @@ def language # Return an array of the language codes defined in the system. def self.defined_language_codes - @defined_language_codes ||= all.collect(&:iso_639_code) + all.collect(&:iso_639_code) end # Given a string +query+, diff --git a/app/views/languages/new.html.erb b/app/views/languages/new.html.erb index fd09f46a..4cf99149 100644 --- a/app/views/languages/new.html.erb +++ b/app/views/languages/new.html.erb @@ -2,7 +2,7 @@ <%= form_for @language, { method: :post, action: 'create', html: {:class => "yform"}} do |f| %> <%= # @action = "Create" - render(:partial => "longform", :for_url => "/#{I18n.locale}/languages", locals: {language_form: f} }) + render(:partial => "longform", :for_url => "/#{I18n.locale}/languages", locals: {language_form: f}) %>