ネストされた仮想属性をRailsでどのようにローカライズすることが可能ですか?Railsでネストされた仮想属性をローカライズ
モデル:
class User < ActiveRecord::Base
attr_accessor :company_information # This is used in callbacks etc
end
とビュー:(en.yml
から)
= 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
翻訳キーactiverecord.attributes.user.company_information.name
とactiverecord.attributes.user.company_information_name
などは取り上げていません。
私はこの解決方法を試してみましたが、フォームに完全に表示されている間に、検証エラーがあると、これは選択されず、デフォルトに戻ります。 提案がありますか? – richard