Files
danbooru/app/controllers/artist_urls_controller.rb
evazion 8649ff6dbe API: remove various associated fields included by default.
Remove various associated fields that were included by default on
certain endpoints. API users can use the only param to include the
full association if they need these fields.

* /artists.json: urls.
* /artist_urls.json: artist.
* /comments.json: creator_name and updater_name.
* /notes.json: creator_name.
* /pools.json: creator_name.
* /posts.json: uploader_name, children_ids, pixiv_ugoira_frame_data.
* /post_appeals.json: is_resolved.
* /post_versions.json: updater_name.
* /uploads.json: uploader_name.
2020-02-15 06:17:11 -06:00

32 lines
682 B
Ruby

class ArtistUrlsController < ApplicationController
respond_to :js, :json, :xml, :html
before_action :member_only, except: [:index]
def index
@artist_urls = ArtistUrl.paginated_search(params).includes(model_includes(params))
respond_with(@artist_urls)
end
def update
@artist_url = ArtistUrl.find(params[:id])
@artist_url.update(artist_url_params)
respond_with(@artist_url)
end
private
def default_includes(params)
if ["json", "xml"].include?(params[:format])
[]
else
[:artist]
end
end
def artist_url_params
permitted_params = %i[is_active]
params.fetch(:artist_url, {}).permit(permitted_params)
end
end