Skip to content

Instantly share code, notes, and snippets.

@mrnugget
Created April 17, 2012 14:37
Show Gist options
  • Save mrnugget/2406382 to your computer and use it in GitHub Desktop.
Save mrnugget/2406382 to your computer and use it in GitHub Desktop.
Fix Issue 52
# Before:
class Admin::BaseController < ApplicationController
before_filter :authenticate_admin!
layout 'admin'
protected
def build_locales_for(object)
available_languages.keys.sort.each do |locale|
object.translations.build(:locale => locale) unless object.translated_locales.include?(locale.to_sym)
end
end
end
# After:
class Admin::BaseController < ApplicationController
before_filter :authenticate_admin!
layout 'admin'
protected
def build_locales_for(object)
available_languages.keys.sort.each do |locale|
## Change starts here
if object.translations.select { |t| t.locale == locale.to_sym }.empty?
object.translations.build(:locale => locale)
end
## Change ends here
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment