activeadminを試していたら、特定の管理ページだけ表示できませんでした。
特定ページだけエラー
作成中管理ページの特定のページprofileモデルの管理画面だけエラーがでます。
TypeError in Admin::Profiles#index
Showing /var/www/html/local.pugiemonn.com/vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-18fd1c23fc60/app/views/active_admin/resource/index.html.arb where line #2 raised:
no implicit conversion of String into Array
Extracted source (around line #20):
def label_text
((localized_label || humanized_method_name) + requirement_text).html_safe
end
# TODO: why does this need to be memoized in order to make the inputs_spec tests pass?
no implicit conversion of String into Array
ってなんでしょうか。
i18nのファイルを編集
i18nのyaml辞書ファイルで配列を指定している箇所を削除したら動きました。どうやら記述する場所を間違っていたみたいです。
config/locales/models/profile/ja.yml
モデルに以下の様な配列を書いていました。
profileモデルの辞書ファイル
ja:
activerecord:
attributes:
profile:
sex:
-
- '男性'
- 1
-
- '女性'
- 2
たぶんactiveadminがこの配列部分を読みに行って失敗してるのですかね。
profileモデルの辞書ファイル
ja:
activerecord:
attributes:
profile:
- sex:
- -
- - '男性'
- - 1
- -
- - '女性'
- - 2
配列部分を削除しました。
再度ページを確認
今度は表示されました(☝ ՞ਊ ՞)☝