File tree 1 file changed +4
-2
lines changed
app/controllers/alchemy/json_api
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,17 @@ module JsonApi
5
5
class PagesController < JsonApi ::BaseController
6
6
before_action :load_page_for_cache_key , only : :show
7
7
8
+ ALLOWED_PUBLIC_VERSION_RANSACK_ATTRIBUTES = %w[ public_on ] . map { |a | "public_version_#{ a } " } . freeze
9
+
8
10
def index
9
11
allowed = Alchemy ::Page . ransackable_attributes
10
12
11
13
jsonapi_filter ( page_scope , allowed ) do |filtered_pages |
12
14
@pages = filtered_pages . result
13
15
if !@pages . all? ( &:cache_page? )
14
- render_pages_json ( allowed ) && return
16
+ render_pages_json ( allowed | ALLOWED_PUBLIC_VERSION_RANSACK_ATTRIBUTES ) && return
15
17
elsif stale? ( last_modified : @pages . maximum ( :published_at ) , etag : @pages . max_by ( &:cache_key ) &.cache_key )
16
- render_pages_json ( allowed )
18
+ render_pages_json ( allowed | ALLOWED_PUBLIC_VERSION_RANSACK_ATTRIBUTES )
17
19
end
18
20
end
19
21
You can’t perform that action at this time.
0 commit comments