2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

no implicit conversion of String into Array と言われました。

Posted at

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

配列部分を削除しました。

再度ページを確認

今度は表示されました(☝ ՞ਊ ՞)☝

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?