enumを利用したransackのラジオボタン検索で少しつまずいたので備忘録用として投稿
ransackの導入やenumの書き方については端折ります。
micropost.rb
enum result: { win: 1, lose: 2, notrade: 3 }
検索できなかった時
_serch_form.html.slim
= search_form_for @q do |f|
h2.my-3 検索
= f.label :result
br.form-check.form-check-inline
= f.radio_button :result_eq, :win, {:checked => true}
= f.radio_button :result_eq, :lose
= f.radio_button :result_eq, :notrade
br
= f.submit nil, class:'btn btn-info'
正しいやつ
_serch_form.html.slim
= search_form_for @q do |f|
h2.my-3 検索
= f.label :result
br.form-check.form-check-inline
= f.radio_button :result_eq, 1, {:checked => true}
= f.radio_button :result_eq, 2
= f.radio_button :result_eq, 3
br
= f.submit nil, class:'btn btn-info'
インデントとか気にしないで下さい。
なぜか最初はハッシュを入力していました。