tardjo
tardjo

Reputation: 1654

how to add new item inside show table active admin in rails

how to add new item inside show table active admin in rails ?

i try this code :

show do |ad|
    default_main_content
    attributes_table do
      row "States : "
      row ad.states.map(&:name)
    end
  end

but the "States" not add inside table?

Upvotes: 3

Views: 2893

Answers (4)

pomodroizer
pomodroizer

Reputation: 41

If you don't want to lose default attributes (database columns) just do:

show do
  attributes_table(*default_attribute_table_rows) do
    row "My new row description" do
      My row value
    end
  end
end

Your new row will be displayed at the bottom of the table

Upvotes: 4

tal weissler
tal weissler

Reputation: 225

If you want to put them in the same row you can do this:

show do |ad|
  default_main_content
  attributes_table do
    row "States : #{ad.states.map(&:name)}"
  end
end

Upvotes: 1

tardjo
tardjo

Reputation: 1654

this is my code :

show do |ad|
    attributes_table do
      row :id 
      row :name
      row :featured
      row :url
      row :amount
      row :application_deadline
      row :accreditation
      row :created_at
      row :updated_at
      row :degree_type
      row :states_name do 
        ad.states.map(&:name)
      end
      row :description
      row :slug
      row :deadline
      row :degree_string
      row :image_file_name
      row :image_content_type
      row :image_file_size
      row :image_updated_at
      row :real_amount
      row :real_deadline
    end
  end

Upvotes: 1

Rajarshi Das
Rajarshi Das

Reputation: 12320

Please fix it in this way

 show do |ad|
  attributes_table do 
   row "Add States" do
     ad.states.map(&:name)
     link_to "Add State", ...
   end
  end
 end

Upvotes: 0

Related Questions