LoginSignup
0
0

More than 1 year has passed since last update.

ActiveAdminのラジオボタンの初期値をセットする方法

Posted at

概要

checkboxであれば、input_html {value: :enabled}で初期値をセットできた(はず)ですが、
radiobuttonだとうまくいかなかったのでnewアクション内で初期値をセットしました。

コード

ActiveAdmin.register Sample do
  controller do
    def new
      @sample = Sample.new
      @sample.show_flg = Sample.show_flgs[:enabled]
    end
  end

  form do |f|
    f.inputs do
      f.input :show_flg, as: :radio, collection: Sample.show_flgs_i18n.invert
    end
    f.actions
  end
0
0
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
0
0