6
4

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 3 years have passed since last update.

ActiveAdmin | filter に as: :string を指定したら、短すぎる maxlength が作られてしまう

6
Last updated at Posted at 2016-01-25

解決

数値型のカラムに対しては as: :numeric を指定すること。

ActiveAdmin.register Example do
  filter :id, as: :string
end

as: :string ではうまく動かない。

問題

数値型に対して filter を作る場合。 as: :string を指定すると。

ActiveAdmin.register Example do
  filter :id, as: :string
end

ActiveAdmin がスキーマ情報を誤解する。
そして短めの <input maxlength=""> をつけてしまう。

<input type="xxxx" maxlength="4">

まとめ

ActiveAdmin filter の as: は。
単にHTML でどんな input を生成するかではなく。

「データ型をどのように扱うか」も含めての指定のようだ。

( どおりで type: :text いう指定ではないわけだ。。。が単にバグのような気もする )

環境

  • activeadmin (1.0.0.pre1 e3a7354)
  • Rails 4.0.0

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

メンター受付

6
4
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
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?