0

When I am trying add new translation:

I18n::Backend::ActiveRecord.new.store_translations(:encoding, :key => value)

I have following error:

ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes for I18n::Backend::ActiveRecord::Translation: locale, key, value

Anybody know how to fix this?

Voldemar Duletskiy
  • 981
  • 1
  • 11
  • 30

1 Answers1

1

I made up patch concern:

module TranslationPatch
  extend ActiveSupport::Concern
  included do
    if defined?(ProtectedAttributes)
      attr_accessible :missing,:locale,:key,:value
    end
  end
end

and included it in locale.rb file:

require 'i18n/backend/active_record'
I18n.backend = I18n::Backend::ActiveRecord.new

I18n::Backend::ActiveRecord::Translation.send(:include,TranslationPatch)
Voldemar Duletskiy
  • 981
  • 1
  • 11
  • 30