controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -30,8 +30,9 @@ class ArtistsController < ApplicationController
|
||||
def index
|
||||
# XXX
|
||||
params[:search][:name] = params.delete(:name) if params[:name]
|
||||
@artists = Artist.paginated_search(params)
|
||||
@artists = @artists.includes(:urls, :tag) if request.format.html?
|
||||
|
||||
@artists = Artist.paginated_search(params).includes(model_includes(params))
|
||||
respond_with(@artists)
|
||||
end
|
||||
|
||||
@@ -78,14 +79,6 @@ class ArtistsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:urls, :tag]
|
||||
end
|
||||
end
|
||||
|
||||
def item_matches_params(artist)
|
||||
if params[:search][:any_name_or_url_matches]
|
||||
artist.name == Artist.normalize_name(params[:search][:any_name_or_url_matches])
|
||||
|
||||
Reference in New Issue
Block a user