Active Admin: Customize only new form

If you just want to hide or show certain fields on the new form (e.g. a field that you generate automatically in the model using before_create), you can do this:

form do |f|
    f.inputs "Member Details" do
        f.input :first_name
        f.input :last_name
        f.input :email
        if !f.object.new_record?
            f.input :password
            f.input :password_confirmation
        end
    end
    f.button :Submit
end

This will hide the password fields when you create a new member in the event that you automatically generate passwords the first time the member is created.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)