5
저는 사용자에게 일반적인 게시물 소유 관계가 있습니다. #index
과 같은 모든 작업에 default_scope를 적용하여 내 게시물 만 나열합니다. 하지만 링크를 따라 가면 #show
동작으로 이동하면 누구의 게시물도 볼 수있는 기능이 필요합니다.ActiveAdmin에서 일부 작업에만 범위를 추가하려면 어떻게해야합니까?
해당 작업에 default_scope를 적용하지 않으려면 어떻게해야합니까?
class Post < ActiveRecord::Base
belongs_to :user
end
ActiveAdmin.register CertificationModel do
controller do
def scoped_collection
current_user.posts
end
end
end
, 당신은 내장 ['scope_to'] (https://github.com/gregbell/active_admin/blob/60d8be97ec2c29a871f55bd28e00ca9ec9257028/docs/2-resource-customization.md#scoping을 사용할 수 있습니다 -the-queries) 메소드를 사용하여 현재 'scoped_collection'으로 수행중인 것과 동일한 작업을 수행합니다. – seanlinsley