ActiveAdmin nested form on #show page

后端 未结 2 355
温柔的废话
温柔的废话 2021-02-04 18:52

Is it possible to add nested form to #show page?

Now i have my admin/posts.rb:

ActiveAdmin.register Post do
  show         


        
2条回答
  •  隐瞒了意图╮
    2021-02-04 19:34

    I use the following recipe when adding this type of info to a show page

        ActiveAdmin.register Post do
          show :title => :email do |post|
            attributes_table do
              row :id
              row :first_name
              row :last_name
            end
            div :class => "panel" do
              h3 "Comments"
              if post.comments and post.comments.count > 0
                div :class => "panel_contents" do
                  div :class => "attributes_table" do
                    table do
                      tr do
                        th do
                          "Comment Text"
                        end
                      end
                      tbody do
                        post.comments.each do |comment|
                          tr do
                            td do
                              comment.text
                            end
                          end
                        end
                      end
                    end
                  end
                end
              else
                h3 "No comments available"
              end
            end
          end
        end
    

提交回复
热议问题