user
user

Reputation: 1381

ActiveAdmin save value from checkbox as boolean

I want to save value from my checkbox's form as boolean, but i have got an array

Chunk of my log "important"=>[""]

or if i checked it

"important"=>["", "true"]

my table

t.boolean :important, :default => false

my form

f.input :important, :as => :check_boxes, collection: [true]

How to fix it?

I think the problem is in my form's input

Upvotes: 8

Views: 13194

Answers (1)

Leonel Galán
Leonel Galán

Reputation: 7167

Use

f.input :important, as: :boolean

Instead. Source - see Formtastic’s documentation which ActiveAdmin is based upon.

EDIT

as: :check_boxes is meant for collections (selecting many values from a collection).

Upvotes: 27

Related Questions