简体   繁体   English

如何在rails中的show table active admin中添加新项目

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

how to add new item inside show table active admin in rails ?如何在rails中的show table active admin中添加新项目?

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?但是“状态”没有添加到表中?

If you don't want to lose default attributes (database columns) just do:如果您不想丢失默认属性(数据库列),请执行以下操作:

show do
  attributes_table(*resource.attributes.keys) 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您的新行将显示在表格底部

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM