怎么可能本地化嵌套虚拟属性在 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 want to localise
= f.button :submit
翻译键(来自en.yml
) like activerecord.attributes.user.company_information.name
and activerecord.attributes.user.company_information_name
没有被拾取。
看来您正在使用 simple_form gem 来生成表单。这对我有用。
en:
simple_form:
labels:
user:
company_information:
name: My Name
简单表格的链接本地化章节 https://github.com/plataformatec/simple_form#i18n可能也有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)