Haytham.Breaka
Haytham.Breaka

Reputation: 155

Boolean on active admin field returns empty instead false (Rails 3.2/Active Admin)

I have a form called User with a boolean attribute called 'confirmed'. When I display all users or try to view each user, the confirmed value is always empty instead of false and I have searched alot and still I don't why this happen. Can anyone help me?

Note: 'confirmed' is shown as empty if it is false only.

Schema Migration:

create_table "users", :force => true do |t|
   t.string   "name"
   t.boolean  "confirmed",        :default => false
   t.datetime "created_at",       :null => false
   t.datetime "updated_at",       :null => false
end

Index function and Form on active admin:

ActiveAdmin.register User do

    index do
        column :id
        column :name
        column :confirmed
        actions
    end

    form do |f|
        f.inputs "User Details" do
            f.input :name
            f.input :confirmed
        end

       f.actions
    end

end

Upvotes: 3

Views: 1154

Answers (1)

Timo Schilling
Timo Schilling

Reputation: 3073

ActiveAdmin.register User do

    index do
        column :id
        column :name
        column :confirmed do |user|
          user.confirmed ? "confirmed" : "unconfirmed"
        end
        # or, but maybe only in 1.x versions
        column :confirmed do |user|
          status_tag user.confirmed
        end
        actions
    end

    form do |f|
        f.inputs "User Details" do
            f.input :name
            f.input :confirmed
        end

       f.actions
    end

end

Upvotes: 2

Related Questions