Tag: 全球化

如何解决“无法批量分配受保护的属性:translations_attributes”错误?

我正在使用Ruby on Rails(3.2.2), globalize3 (0.2.0)和batch_translations (0.1.2)ruby-gems。 我想解决使用batch_translations ruby​​-gem时产生的以下问题: ActiveModel::MassAssignmentSecurity::Error in Admin::ArticlesController#update Can’t mass-assign protected attributes: translations_attributes 在我的ROOT_RAILS/Gemfile文件中,我有: … gem ‘globalize3’ gem ‘batch_translations’ 在我的ROOT_RAILS/app/models/admin/article.rb文件中,我有: class Admin::Article < ActiveRecord::Base translates :title # This is needed to make the batch_translations to work. accepts_nested_attributes_for :translations … end 在我的ROOT_RAILS/app/views/admin/articles/_form.html.erb文件中,我有: admin_article_path) do |f| %> English translation: Italiano translation: <% # Note: […]

在Rails中本地化嵌套的虚拟属性

如何在Rails中本地化嵌套的虚拟属性 ? 该模型: class User < ActiveRecord::Base attr_accessor :company_information # This is used in callbacks etc end 和观点: = simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: ‘form-horizontal’}) do |f| = devise_error_messages! = f.input :email = f.input :password = f.input :password_confirmation = f.simple_fields_for :company_information do |c| = c.input :name # This is what I […]

全局化rails中的文件(附件,图像)

我们可以使用globalize gem来全局化模型中的文本字段。 对于员工的全球化(翻译)’指定’属性,我们使用translates :designation员工模型中的translates :designation , employee.translations打印员工对象的翻译(每个支持的语言环境的一个对象,在相应的语言环境中指定)。 我有一个特定于模型的属性(员工的图像),它是一个回形针附件。 需要全局化图像,以便employee.image将为默认区域设置(:en)提供实际图像, employee.image.translations将返回图像的所有翻译(每个支持的区域设置的一个图像/回形针附件) 如何全球化铁轨中的回形针附件?