Customising just a single property in a Resource

Viewed 25

I have a simple Rails Model which has several columns in the database. I then have an ActiveAdmin Resource for this model and by default it renders me a nice index, show and form views with all of the columns and I'm able to do all the standard CRUD operations.

Is it possible to customise one of the columns without overwriting index, show and form functions and writing out all of the individual columns again?

For example if I want to change how a single column is rendered I know I can do this:

ActiveAdmin.register Product do
    permit_params :name, :description, :price, :weight

    index do
        selectable_column
        column :id
        column :name
        column :description
        column :price do |f|
            text_field "#{f.price} EUR"
        end
    end

    show do
        row :id
        row :name
        row :description
        row :price do |f|
            text_field "#{f.price} EUR"
        end
        row :weight
    end
end

But I would instead like to do something like this:

ActiveAdmin.register Product do
    permit_params :name, :description, :price, :weight

    # param_view is (to my knowlege) an imaginary method
    param_view :price do |p|
        text_field "#{f.price} EUR"
    end
end

Is this somehow possible? What about just hiding a single property?

0 Answers
Related