diff --git a/app/models/site.rb b/app/models/site.rb index faa7ece37..46038eb2b 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -40,17 +40,15 @@ class Site end METAS.each do |meta| - define_method meta do + define_method meta do |locale| fetch_meta = self.site_metas.where(key: meta).limit(1) - fetch_meta.blank? ? nil : fetch_meta[0].i18n_variable + fetch_meta.blank? ? nil : fetch_meta[0].title_translations[locale] end define_method "#{meta}=" do |values| - if a = self.send(meta) - a.update_attributes(values) - else - a = self.site_metas.build(key: meta) - a.build_i18n_variable(values) - end + fetch_meta = self.site_metas.where(key: meta).limit(1)[0] rescue nil + fetch_meta = self.site_metas.build(key: meta) if fetch_meta.blank? + fetch_meta.title_translations = values + fetch_meta.save end end diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 4ce99df13..cdd7ea541 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -38,9 +38,8 @@
<%= (t 'admin.site_keywords_help').html_safe %>
<%= (t 'admin.site_description_help').html_safe %>
<%= (t 'admin.site_footer_help').html_safe %>