Skip to content

Commit

Permalink
scopes shouldn't require generate flag
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonborg committed May 9, 2017
1 parent 77a043f commit 9b3a75a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class ApplicationController < ActionController::API

private

def scopes_present?
params[:generate] == 'true' || scopes_configuration.any? { |scope, _options| params.key? scope }
end

def geo_params
params.permit(:address, :lat, :long, :radius)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/office_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
@office_locations = apply_scopes(geo.find_office_locations).each do |off|
off.calculate_distance(geo.coordinates.latlon)
end
elsif params[:generate] == 'true'
elsif scopes_present?
@office_locations = apply_scopes(OfficeLocation).active.order(:office_id)
else
send_index_files :office_locations
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index
rep.sort_offices(geo.coordinates.latlon)
end
@district = geo.district
elsif params[:generate] == 'true'
elsif scopes_present?
@reps = apply_scopes(Rep).active.order(:bioguide_id)
else
send_index_files :reps
Expand Down

0 comments on commit 9b3a75a

Please sign in to comment.