Fix bugs after i18n_variable removal
This commit is contained in:
		
							parent
							
								
									ad3ec43a00
								
							
						
					
					
						commit
						12f9f666eb
					
				| 
						 | 
				
			
			@ -42,17 +42,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
 | 
			
		||||
  
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,9 +47,8 @@
 | 
			
		|||
						<div class="control-group">
 | 
			
		||||
							<label class="control-label"><%= t 'admin.site_keywords' %></label>
 | 
			
		||||
							<div class="controls">
 | 
			
		||||
								<% #TODO: set keywords into meta %>
 | 
			
		||||
								<%= f.fields_for :keywords, @site.keywords do |f| %>
 | 
			
		||||
									<%= f.text_area locale, :class => "input-xxlarge textarea-height-s" %>
 | 
			
		||||
								<%= f.fields_for :keywords do |f| %>
 | 
			
		||||
									<%= f.text_area locale, :class => "input-xxlarge textarea-height-s", :value => (@site.keywords(locale) rescue nil) %>
 | 
			
		||||
								<% end %>
 | 
			
		||||
								<p class="help-block"><%= (t 'admin.site_keywords_help').html_safe %></p>
 | 
			
		||||
							</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -57,8 +56,8 @@
 | 
			
		|||
						<div class="control-group">
 | 
			
		||||
							<label class="control-label"><%= t 'admin.site_description' %></label>
 | 
			
		||||
							<div class="controls">
 | 
			
		||||
								<%= f.fields_for :description_translations do |f| %>
 | 
			
		||||
									<%= f.text_area locale, :class => "input-xxlarge textarea-height-s", :value => (@site.description_translations[locale] %>
 | 
			
		||||
								<%= f.fields_for :description do |f| %>
 | 
			
		||||
									<%= f.text_area locale, :class => "input-xxlarge textarea-height-s", :value => (@site.description(locale) rescue nil) %>
 | 
			
		||||
								<% end %>
 | 
			
		||||
								<p class="help-block"><%= (t 'admin.site_description_help').html_safe %></p>
 | 
			
		||||
							</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +66,7 @@
 | 
			
		|||
							<label class="control-label"><%= t 'admin.site_footer' %></label>
 | 
			
		||||
							<div class="controls">
 | 
			
		||||
								<%= f.fields_for :footer_translations do |f| %>
 | 
			
		||||
									<%= f.text_area locale, :class => "tinymce_textarea input-xxlarge", :value => (@site.footer_translations[locale] %>
 | 
			
		||||
									<%= f.text_area locale, :class => "tinymce_textarea input-xxlarge", :value => (@site.footer_translations[locale] rescue nil) %>
 | 
			
		||||
								<% end %>
 | 
			
		||||
								<p class="help-block"><%= (t 'admin.site_footer_help').html_safe %></p>
 | 
			
		||||
							</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -76,7 +75,7 @@
 | 
			
		|||
							<label class="control-label"><%= t 'admin.site_sub_menu' %></label>
 | 
			
		||||
							<div class="controls">
 | 
			
		||||
								<%= f.fields_for :sub_menu_translations do |f| %>
 | 
			
		||||
									<%= f.text_area locale, :class => "tinymce_textarea input-xxlarge", :value => (@site.sub_menu_translations[locale] %>
 | 
			
		||||
									<%= f.text_area locale, :class => "tinymce_textarea input-xxlarge", :value => (@site.sub_menu_translations[locale] rescue nil) %>
 | 
			
		||||
								<% end %>
 | 
			
		||||
							</div>
 | 
			
		||||
						</div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue