빠른 Activeadmin 치트 시트

더보기:


  • https://activeadmin.info/
  • Activeadmin Cheat Sheet

  • '새 게시물' 비활성화




    ActiveAdmin.register Post do
      actions :index, :edit
      # or: config.clear_action_items!
    end
    


    기타 도우미




    status_tag "Done"           # Gray
    status_tag "Finished", :ok  # Green
    status_tag "You", :warn     # Orange
    status_tag "Failed", :error # Red
    





    column :foo
    



    column :title, sortable: :name do |post|
      strong post.title
    end
    


    사용자 지정 작업



    모델에 대한 사용자 지정 작업을 정의할 수 있습니다.
    {: .-설정}

    before_filter only: [:show, :edit, :publish] do
      @post = Post.find(params[:id])
    end
    


    경로를 확인




    member_action :publish, method: :put do
      @post.publish!
      redirect_to admin_posts_path, notice: "The post '#{@post}' has been published!"
    end
    


    인덱스에 연결




    index do
      column do |post|
        link_to 'Publish', publish_admin_post_path(post), method: :put
      end
    end
    


    그리고 show/edit에서 링크합니다.




    action_item only: [:edit, :show] do
      @post = Post.find(params[:id])
      link_to 'Publish', publish_admin_post_path(post), method: :put
    end
    


    사이드바 필터




    filter :email
    filter :username
    


    범위 나열



    특정 범위로 목록을 필터링할 수 있습니다.
    {: .-설정}

    scope :draft
    scope :for_approval
    



    scope :public, if: ->{ current_admin_user.can?(...) }
    scope "Unapproved", :pending
    scope("Published") { |books| books.where(:published: true) }
    

    좋은 웹페이지 즐겨찾기