빠른 Activeadmin 치트 시트
6314 단어 amctiveadmincheatsheet
더보기:
'새 게시물' 비활성화
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) }
Reference
이 문제에 관하여(빠른 Activeadmin 치트 시트), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/hoanganhlam/quick-activeadmin-cheat-sheet-2g2g텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)