Skip to content

Commit f263b60

Browse files
committed
Fix location changing
1 parent bd7c994 commit f263b60

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

app/models/opportunity.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,12 @@ def assign_random_id
305305

306306
protected
307307
def set_location_city
308-
self.location_city = begin
309-
locations = []
310-
begin
311-
locations = self.team.cities.compact.select { |city| self.location.include?(city) }
312-
end while locations.blank? && add_opportunity_locations_to_team && set_location_city
313-
locations.join("|")
314-
end unless self.location.nil?
315-
errors.add(:location, "is not valid, please specify one or more cities separated by | (e.g. Miami, FL | San Francisco). put 'anywhere' if location doesn't matter") if !self.location.nil? and !valid_location_city
316-
self.location_city
308+
add_opportunity_locations_to_team
309+
locations = self.team.cities.compact.select { |city| self.location.include?(city) }
310+
311+
return if locations.blank? && anywhere?(self.location)
312+
313+
self.location_city = locations.join("|")
317314
end
318315

319316
def add_opportunity_locations_to_team

app/views/opportunities/_form.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
-if @team.team_locations.any?
2020
=j.label :location do
2121
== Select one or more locations where the candidate must be located or #{link_to('add/manage team locations', edit_team_locations_path(@team))}
22-
=j.select(:location, @team.cities+["anywhere"], {:selected => @job.location.split("|")}, {:multiple => true})
22+
=j.select(:location, @team.cities+["anywhere"], {:selected => (@job.location.blank? ? [] : @job.location.split("|"))}, {:multiple => true})
2323
-else
2424
=j.label :location, 'Specify the city/location where the candidate must be located'
2525
=j.text_field :location

0 commit comments

Comments
 (0)