From adce7aa50e1ea445ebb885c6a72215b4fc19bf88 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 24 Nov 2016 11:52:13 -0700 Subject: [PATCH 1/5] extraneous brace --- app/views/languages/new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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}) %> From 73e6946a30d41e02288a5b1ccd79d88a76ec215d Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 24 Nov 2016 11:53:03 -0700 Subject: [PATCH 2/5] update languages & accessors --- app/controllers/languages_controller.rb | 10 ++++++++++ app/models/language.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index bc2dbe15..0bd4485f 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -47,6 +47,11 @@ def create respond_to do |format| if @language.save + ActiveRecord::Base.descendants.each do |c| + # Update accessors for models that have accessors defined + c.globalize_accessors(locales: Language.defined_language_codes) if c.respond_to?(:globalize_locales) + end + flash[:notice] = t('languages.new.success') format.html { redirect_to(@language) } format.xml { render :xml => @language, :status => :created, :location => @language } @@ -64,6 +69,11 @@ def update respond_to do |format| if @language.update_attributes(params[:language]) + ActiveRecord::Base.descendants.each do |c| + # Update accessors for models that have accessors defined + c.globalize_accessors(locales: Language.defined_language_codes) if c.respond_to?(:globalize_locales) + end + flash[:notice] = t('languages.edit.success') format.html { redirect_to(@language) } format.xml { head :ok } 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+, From 46439fccc8c2dfa1548d04ab8df1228a4dc186b3 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 24 Nov 2016 11:55:05 -0700 Subject: [PATCH 3/5] dryer --- app/controllers/languages_controller.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index 0bd4485f..fbd620d5 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -47,10 +47,7 @@ def create respond_to do |format| if @language.save - ActiveRecord::Base.descendants.each do |c| - # Update accessors for models that have accessors defined - c.globalize_accessors(locales: Language.defined_language_codes) if c.respond_to?(:globalize_locales) - end + update_accessors flash[:notice] = t('languages.new.success') format.html { redirect_to(@language) } @@ -69,10 +66,7 @@ def update respond_to do |format| if @language.update_attributes(params[:language]) - ActiveRecord::Base.descendants.each do |c| - # Update accessors for models that have accessors defined - c.globalize_accessors(locales: Language.defined_language_codes) if c.respond_to?(:globalize_locales) - end + update_accessors flash[:notice] = t('languages.edit.success') format.html { redirect_to(@language) } @@ -104,4 +98,12 @@ def matching format.js { render :partial => "autocomplete" } end end + + private + def update_accessors + ActiveRecord::Base.descendants.each do |c| + # Update accessors for models that have accessors defined + c.globalize_accessors(locales: Language.defined_language_codes) if c.respond_to?(:globalize_locales) + end + end end From 528478dcb95b9505fe3113c98fed6b29996ca7f8 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 24 Nov 2016 12:10:11 -0700 Subject: [PATCH 4/5] move comment --- app/controllers/languages_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index fbd620d5..54e01c37 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -100,9 +100,10 @@ def matching end private + + # Update accessors for models that have accessors defined def update_accessors ActiveRecord::Base.descendants.each do |c| - # Update accessors for models that have accessors defined c.globalize_accessors(locales: Language.defined_language_codes) if c.respond_to?(:globalize_locales) end end From bc91875f5faa252590a46347e20d4870abcd1515 Mon Sep 17 00:00:00 2001 From: Luis Date: Thu, 24 Nov 2016 12:10:17 -0700 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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