rails-admin

How can I customize only a field in rails_admin?


I have a field for which rails_admin generates a textfield, but I'd like it to use a <select> tag instead. I customized the field like this, in my initializer:

RailsAdmin.config do |config|
  config.model User do
    update do
      field :state do
        partial "user_state_partial"
      end
    end
  end
end

I've tested it, and it works. The problem is, by doing like this ( I tried with an edit block too ), the only field left, is the one I'm customizing. Is there any way of telling rails_admin to just assume the defaults for the other fields?


Solution

  • Once you have defined one field, you have to define all fields that you want to use. The default is all fields.

    RailsAdmin.config do |config|
      config.model User do
        update do
          field :name
          field :surname
          field :state do
            partial "user_state_partial"
          end
        end
      end
    end